/ Published in: jQuery

The markup would look like this:
<code> <input class="swap-value" type="text" value="Search"/ ></code>
<code> <input class="swap-value" type="text" value="Search"/ ></code>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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"); } }); });
Comments
