/ Published in: jQuery

Adding input values and clearing on focus
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('#ctl00_ctl05_ctl00_UserNameText').attr('value', 'username'); $('#ctl00_ctl05_ctl00_UserNameText').focus(function() { if (this.value == 'username') {this.value = '';} }); $('#ctl00_ctl05_ctl00_UserNameText').blur(function() { if (this.value == '') {this.value = 'username';} }); $('#ctl00_ctl05_ctl00_PasswordText').attr('value', 'password'); $('#ctl00_ctl05_ctl00_PasswordText').focus(function() { if (this.value == 'password') {this.value = '';} }); $('#ctl00_ctl05_ctl00_PasswordText').blur(function() { if (this.value == '') {this.value = 'password';} });
Comments
