/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function watermark ($obj) { var prev; $obj.each(function() { if ($(this).attr("title")) $(this).val($(this).attr("title")).addClass("greyout"); }); $obj .focus(function() { if ($(this).val()==$(this).attr("title")) { prev = $(this).val(); $(this).val("").removeClass("greyout"); } }) .blur(function() { if($(this).val()=="") { $(this).val(prev).addClass("greyout");; } }); }