Posted By

ReeceMarsland on 12/21/09


Tagged

search jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jannisg


jQuery Search Text Replace


 / Published in: jQuery
 

  1. var searchBox = $("#edit-search-theme-form-1");
  2. var searchBoxDefault = "Enter keywords";
  3. searchBox.attr("value", searchBoxDefault);
  4.  
  5. searchBox.focus(function(){
  6. if(jQuery.trim($(this).attr("value")) == searchBoxDefault) $(this).attr("value", "");
  7. });
  8.  
  9. searchBox.blur(function(){
  10. if(jQuery.trim($(this).attr("value")) == "") $(this).attr("value", searchBoxDefault);
  11. })

Report this snippet  

You need to login to post a comment.