-
-
Save iamntz/c8e3d2577c9e95fc48e1 to your computer and use it in GitHub Desktop.
placeholder.v2
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 enablePlaceholderSupport(b){var d=jQuery,b=b||"body",c=document.createElement("input"),e=("placeholder" in c),a=function(f){if(d(f).val()===d(f).data("placeholder")){d(f).val("")}};if(!e){d("input[placeholder]",b).each(function(){var f=d(this),h=f.attr("placeholder"),g=d.trim(this.value);if(typeof f.data("placeholder")!=="undefined"){return}f.data("placeholder",h);if(g==""){d(this).val(h).addClass("placeholder")}f.bind("focus.ntz_placeholder",function(){if(this.value==d(this).data("placeholder")){d(this).val("").removeClass("placeholder")}}).bind("blur.ntz_placeholder",function(){if(this.value.length===0){d(this).val(h).addClass("placeholder")}})});d("form").bind("submit.ntz_placeholder",function(){d("input[placeholder]",this).each(function(){a(this)})});d(window).bind("unload.ntz_placeholder",function(){a(d("input[placeholder]",this))})}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment