Skip to content

Instantly share code, notes, and snippets.

@smonteverdi
Created August 17, 2012 15:51
Show Gist options
  • Save smonteverdi/3380075 to your computer and use it in GitHub Desktop.
Save smonteverdi/3380075 to your computer and use it in GitHub Desktop.
jQquery: Clear input on focus, restore on blur
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