Skip to content

Instantly share code, notes, and snippets.

@mynameispj
Created March 29, 2012 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mynameispj/2237482 to your computer and use it in GitHub Desktop.
Save mynameispj/2237482 to your computer and use it in GitHub Desktop.
jQuery snippet to remove and replace default form input text on click
$('form.form-search input').focus(function() {
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$('form.form-search input').blur(function() {
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment