Auto Clear Search Box Value on focus


/ Published in: jQuery
Save to your folder(s)



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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.