Clear Input field on focus_js


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



Copy this code and paste it in your HTML
  1. $('.default-value').each(function() {
  2. var default_value = this.value;
  3. $(this).focus(function() {
  4. if(this.value == default_value) {
  5. this.value = '';
  6. }
  7. });
  8. $(this).blur(function() {
  9. if(this.value == '') {
  10. this.value = default_value;
  11. }
  12. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.