Posted By

joshangell on 04/03/11


Tagged

textmate jQ


Versions (?)

jQuery form clearing


 / Published in: jQuery
 

  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  

You need to login to post a comment.