Search This Blog

Wednesday, August 25, 2010

Manage Search textbox value with jQuery

How to manage search textbox value when there is some default text in textbox and on focus or blur that text will not appear using jQuery??

See the example :

$(function(){
    //set default value:
    $("#searchbox")
      .val('search?'); // textbox contains default value 'search'
      .focus(function(){this.val('')})
      .blur(function(){
        (this.val() === '')? this.val('search?') : null;
      });
});

No comments:

Post a Comment