/ Published in: jQuery

Replaces the pre-defined text of a textbox (e.g. the purpose of the textbox) when the textbox gets focussed, and resets the text if it blurs when empty
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<input type="text" value="Name" rel="Name" class="replace" /> $(".replace") .focus(function(){ if ($(this).val() === $(this).attr("rel")) { $(this).val("").css("color", "#000000"); } }) .blur(function(){ if ($(this).val() === "") { $(this).val($(this).attr("rel")).css("color", "#5e6a72"); } });
Comments
