How To Create An Input Field Watermark Using jQuery
erics, September 20th, 2011
Here is a VERY simplistic watermark code snippet. It has the distinct disadvantage of submitting the watermark string as the field value, and does not set the initial field value either…YMMV…
1 2 3 4 5 6 7 |
jQuery('#yourInput') .focusin(function() { if (jQuery('#yourInput').val() == 'Enter keywords to search for') jQuery('#yourInput').val(''); }) .focusout(function() { if (jQuery('#yourInput').val() == '') jQuery('#yourInput').val('Enter keywords to search for'); }); |
http://api.jquery.com/focusin/