Hey all. I have an input element used for search.. eg <input id="foo" name="foo" value="" type="text">
When the dom is loaded, I'm changing the value of this input to 'Search keyword..' and I've added an event handler for the 'focus' event, so that the value of the input changes to blank if you focus on it. I've tried adding a second function hoping to change the value back to 'Search keyword..' if you click anywhere else (so the focus is no longer on the input). The code below however isn't doing that for me. $(document).ready(function() { $('input#foo').value('search keyword...'); $('input#foo').focus(function() { $(this).val(''); }, function() { $(this).val('Search keyword..'); }); }); Should I be using a different method? Bind perhaps? I've tried click and get the same results as focus.