Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created November 30, 2008 02:18
Show Gist options
  • Save jschementi/30370 to your computer and use it in GitHub Desktop.
Save jschementi/30370 to your computer and use it in GitHub Desktop.
JQuery Watermark
$(document).ready(function() {
swapValues = []
$(".watermark").each(function(i) {
$(this).addClass("gray")
swapValues[i] = $(this).val()
$(this).focus(function() {
if($(this).val() == swapValues[i]) {
$(this).val("")
$(this).removeClass("gray")
}
}).blur(function() {
if($.trim($(this).val())=="") {
$(this).val(swapValues[i])
$(this).addClass("gray")
}
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment