jQuery form clearing


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. jQuery('input, textarea').each(function() {
  2. var defaultval = this.value;
  3.  
  4. jQuery(this).focus(function() {
  5. if(this.value == defaultval) {
  6. this.value = '';
  7. }
  8. });
  9.  
  10. jQuery(this).blur(function() {
  11. if(this.value == '') {
  12. this.value = defaultval;
  13. }
  14. });
  15. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.