Created
May 16, 2012 15:30
-
-
Save radius/2711306 to your computer and use it in GitHub Desktop.
Input Placeholder jQuery Plugin
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
$.fn.inputPlaceholder = function(options){ | |
return $(this).each(function() { | |
var options = jQuery.extend({ | |
text: $(this).attr('placeholder') | |
},options); | |
if($(this).val() == '') { | |
$(this).val(options.text); | |
} | |
$(this) | |
.focus(function(e){ | |
if($(this).val() == options.text){ | |
$(this).val(''); | |
} | |
}) | |
.blur(function(e){ | |
if (this.value == '') { | |
this.value = options.text; | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
previous version didnt work for multiple instances on one page