/ Published in: jQuery
The markup would look like this:
<input class="swap-value" type="text" value="Search"/ >
Expand |
Embed | Plain Text
swapValue = []; $(".swap-value").each(function(i){ swapValue[i] = $(this).val(); $(this).focus(function(){ if ($(this).val() == swapValue[i]) { $(this).val(""); } $(this).addClass("focus"); }).blur(function(){ if ($.trim($(this).val()) == "") { $(this).val(swapValue[i]); $(this).removeClass("focus"); } }); });
You need to login to post a comment.
