Posted By

Some0ne on 01/28/11


Tagged

clear jquery inputs


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

virendrakryadav
dubogii


Clear default text in an input box on focus


 / Published in: jQuery
 

  1. $('input').each(function() {
  2.  
  3. var default_value = this.value;
  4.  
  5. $(this).focus(function() {
  6. if(this.value == default_value) {
  7. this.value = '';}
  8. });
  9.  
  10. $(this).blur(function() {
  11. if(this.value == '') {
  12. this.value = default_value;}
  13. });
  14. });

Report this snippet  

You need to login to post a comment.