jQuery Search Text Replace


/ Published in: jQuery



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.