The next code needs jQuery to be included:
jQuery(function($){ var input = $('input.text'); // input text field var default_value = input.val(); input.focus(function(){ if ($.trim($(input).val()) == default_value) input.val(''); }); input.blur(function(){ if ($.trim($(input).val()) == '') input.val(default_value); }); });
Or just use placeholder html5 feature:
<form> <input name="q" placeholder="search..."> </form>
Test html5 placeholder example:
