D'oh! Found the answer @
http://groups.google.com/group/jquery-en/browse_thread/thread/491b63a04680ba50/c564d60307f13e1e?lnk=gst&q=unfocus#c564d60307f13e1e

The solution was to not provide 2 functions, but rather setup a blur
method on the element if anyone else runs into this.

On Mar 6, 12:01 pm, mederOmuraliev <[EMAIL PROTECTED]> wrote:
> 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.

Reply via email to