Posted By

supermauerbros on 08/03/10


Tagged

plugin clear search jquery focus Blur


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jeremyalfordgmailcom


Auto Clear Search Box Value on focus


 / Published in: jQuery
 

URL: http://bassistance.de/2007/01/23/unobtrusive-clear-searchfield-on-focus/

  1. $.fn.search = function() {
  2. return this.focus(function() {
  3. if( this.value == this.defaultValue ) {
  4. this.value = "";
  5. }
  6. }).blur(function() {
  7. if( !this.value.length ) {
  8. this.value = this.defaultValue;
  9. }
  10. });
  11. };
  12. $("#s").search();

Report this snippet  

You need to login to post a comment.