Skip to content

Instantly share code, notes, and snippets.

@jubalm
Created April 27, 2012 08:00
Show Gist options
  • Save jubalm/2507219 to your computer and use it in GitHub Desktop.
Save jubalm/2507219 to your computer and use it in GitHub Desktop.
jQuery clear on focus
// Clear Form on Focus
$('#search input[type="text"]').each(function() {
var default_value = this.value;
$(this).focus(function() {
if(this.value == default_value) {
this.value = '';
}
});
$(this).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