Created
March 29, 2012 13:36
-
-
Save mynameispj/2237482 to your computer and use it in GitHub Desktop.
jQuery snippet to remove and replace default form input text on click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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