Created
August 17, 2012 15:51
-
-
Save smonteverdi/3380075 to your computer and use it in GitHub Desktop.
jQquery: Clear input on focus, restore on blur
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
var default_value = "Select by city,state or zip"; | |
$('#searchform #s').val(default_value); | |
$('#searchform #s').focus(function(){ | |
if(this.value == default_value) { | |
this.value = ''; | |
} | |
}); | |
$('#searchform #s').blur(function(){ | |
if(this.value == '') { | |
this.value = default_value; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment