/ Published in: jQuery

See also the [plain JavaScript version](http://snipplr.com/view/41717/default-value-for-input-fields/).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var elem = $(':text'); // delete default value on focus elem.focus(function() { if ( this.value == this.defaultValue ) { this.value = ''; } }); // regain default value on blur elem.blur(function() { if ( this.value == '' ) { this.value = this.defaultValue; } });
Comments
