/ Published in: jQuery

Specifiy a default value to input text field. OnFocus, the default value clear and let you type a new value. If typed value is erased then the default value is set back.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(document).ready(function() { swapValue = []; $("#qvtit-qvtit").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"); } }); }); }); </script>
Comments
