Skip to content

Instantly share code, notes, and snippets.

@wilkerlucio
Created March 3, 2009 13:36
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 wilkerlucio/73318 to your computer and use it in GitHub Desktop.
Save wilkerlucio/73318 to your computer and use it in GitHub Desktop.
Watermark for jQuery
(function($) {
$.fn.watermark = function() {
return this.each(function() {
this._watermark_base = this.value;
$(this).focus(function() {
if (this._watermark_base == this.value) {
this.value = '';
}
});
$(this).blur(function() {
if (this.value == '') {
this.value = this._watermark_base;
}
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment