Skip to content

Instantly share code, notes, and snippets.

@pixelrevision
Created November 19, 2012 22:24
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 pixelrevision/4114441 to your computer and use it in GitHub Desktop.
Save pixelrevision/4114441 to your computer and use it in GitHub Desktop.
jquery form autoclear
$(document).ready(function(){
$(document).find("[data-autoclear]").each(function(){
$(this).data("clearValue", $(this).val());
$(this).focus(function(){
var cv = $(this).data("clearValue");
if($(this).val() === cv){
$(this).val("");
}
});
$(this).focusout(function(){
if($(this).val() === ""){
var cv = $(this).data("clearValue");
$(this).val(cv);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment