/ Published in: jQuery
If included in a global javascript, whenever an input receives focus it will clear the default value. If the element loses focus without any user input then it will put the default value back in there. Useful for when you aren't using <label> and putting the label in the value of the text field instead.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('input[type=text]').focus(function(){ if (this.defaultValue==this.value){this.value = "";} }); $('input[type=text]').blur(function(){ if (this.value==""){this.value=this.defaultValue;} });
URL: http://www.golfnyguide.com