Adding input values and clearing on focus


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

Adding input values and clearing on focus


Copy this code and paste it in your HTML
  1. $('#ctl00_ctl05_ctl00_UserNameText').attr('value', 'username');
  2. $('#ctl00_ctl05_ctl00_UserNameText').focus(function() { if (this.value == 'username') {this.value = '';} });
  3. $('#ctl00_ctl05_ctl00_UserNameText').blur(function() { if (this.value == '') {this.value = 'username';} });
  4. $('#ctl00_ctl05_ctl00_PasswordText').attr('value', 'password');
  5. $('#ctl00_ctl05_ctl00_PasswordText').focus(function() { if (this.value == 'password') {this.value = '';} });
  6. $('#ctl00_ctl05_ctl00_PasswordText').blur(function() { if (this.value == '') {this.value = 'password';} });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.