Clear default text in an input box on focus


/ Published in: jQuery



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.