forked from Topener/jQuery-html5-placeholder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml5placeholder.jquery.min.js
6 lines (5 loc) · 1.09 KB
/
html5placeholder.jquery.min.js
1
2
3
4
5
6
// HTML5 placeholder plugin version 1.01
// Copyright (c) 2010-The End of Time, Mike Taylor, http://miketaylr.com
// MIT Licensed: http://www.opensource.org/licenses/mit-license.php
(function(b){var f="placeholder"in document.createElement("input"),g=b.browser.opera&&b.browser.version<10.5;b.fn.placeholder=function(c){c=b.extend({},b.fn.placeholder.defaults,c);var h=c.placeholderCSS.left;return f?this:this.each(function(){var a=b(this),i=b.trim(a.val()),j=a.width(),k=a.height(),e=this.id?this.id:"placeholder"+ +new Date,d=a.attr("placeholder");d=b("<label for="+e+">"+d+"</label>");c.placeholderCSS.width=j;c.placeholderCSS.height=k;c.placeholderCSS.left=g&&(this.type=="email"||
this.type=="url")?"11%":h;d.css(c.placeholderCSS);if(!i){a.wrap(c.inputWrapper);a.attr("id",e).after(d)}a.focus(function(){b.trim(a.val())||a.next().hide()});a.blur(function(){b.trim(a.val())||a.next().show()})})};b.fn.placeholder.defaults={inputWrapper:'<span style="position:relative"></span>',placeholderCSS:{font:"0.75em sans-serif",color:"#bababa",position:"absolute",left:"5px",top:"3px","overflow-x":"hidden"}}})(jQuery);