Skip to content

Instantly share code, notes, and snippets.

@rc1
Created September 30, 2010 18:18
Show Gist options
  • Select an option

  • Save rc1/605046 to your computer and use it in GitHub Desktop.

Select an option

Save rc1/605046 to your computer and use it in GitHub Desktop.
// add js-clear class to input to enable
function defaultInputs(className) {
$('input.' + className).each( function () {
$(this).bind('focus', function () {
$this = $(this);
if($this.val() == this.defaultValue) {
$this.val('');
}
});
$(this).bind('blur', function () {
$this = $(this);
if($this.val().length == 0) {
$this.val(this.defaultValue);
}
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment