Created
May 2, 2013 07:57
-
-
Save Takaya213/5500799 to your computer and use it in GitHub Desktop.
A watermark effect for input boxes.
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
(function($) { | |
$.fn.watermark = function() { | |
return this.each(function() { | |
var obj = $(this); | |
var initialText = obj.val(); | |
obj.focus(function() { | |
if (obj.val() === initialText) | |
obj.val(""); | |
}); | |
obj.blur(function() { | |
if (obj.val() === "") | |
obj.val(initialText); | |
}); | |
}); | |
}; | |
})(jQuery); | |
$(document).ready(function() { | |
$('.watermark').watermark(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment