Skip to content

Instantly share code, notes, and snippets.

@ivandoric
Created April 23, 2014 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandoric/11215207 to your computer and use it in GitHub Desktop.
Save ivandoric/11215207 to your computer and use it in GitHub Desktop.
jQuery: Clear input and textarea fields on click
jQuery(function(){
jQuery('input, textarea').each(function(){
var txtval = jQuery(this).val();
jQuery(this).focus(function(){
jQuery(this).val('')
});
jQuery(this).blur(function(){
if(jQuery(this).val() == ""){
jQuery(this).val(txtval);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment