Skip to content

Instantly share code, notes, and snippets.

@morsdyce
Created April 30, 2014 22:45
Show Gist options
  • Save morsdyce/11440535 to your computer and use it in GitHub Desktop.
Save morsdyce/11440535 to your computer and use it in GitHub Desktop.
input[type="text"] toggle default value or empty #jquery
//// input[type="text"] toggle default value
$('input[type="text"]').blur(function() {
if (this.value == '') this.value = this.defaultValue;
});
$('input[type="text"]').focus(function() {
if (this.value == this.defaultValue) this.value = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment