Posted By

rickygri on 11/28/12


Tagged

forms jquery


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

avinay
Beppoi


Clear form input on focus


 / Published in: JavaScript
 

Clear text input when the user selects it (on focus)

  1. $.fn.search=function(){return this.focus(function(){if(this.value==this.defaultValue){this.value=""}}).blur(function(){if(!this.value.length){this.value=this.defaultValue}})}
  2. $("input, textarea").search();

Report this snippet  

You need to login to post a comment.