/ Published in: JavaScript
Clear text input when the user selects it (on focus)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.fn.search=function(){return this.focus(function(){if(this.value==this.defaultValue){this.value=""}}).blur(function(){if(!this.value.length){this.value=this.defaultValue}})} $("input, textarea").search();