Created
November 19, 2012 22:24
-
-
Save pixelrevision/4114441 to your computer and use it in GitHub Desktop.
jquery form autoclear
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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