效果:http://hovertree.com/texiao/jquery/43/效果二:http://hovertree.com/texiao/jquery/43/1/请在IE中体验。 1、创建JS文件:jquery.JPlaceholder.jsjs代码如下:/* * j ...
效果:http://hovertree.com/texiao/jquery/43/
效果二:http://hovertree.com/texiao/jquery/43/1/
请在IE中体验。
1、创建JS文件:jquery.JPlaceholder.js
js代码如下:
/* * jQuery placeholder, fix for IE6,7,8,9* hovertree.com */var JPlaceHolder = { //检测 _check : function(){ return 'placeholder' in document.createElement('input'); }, //初始化 init : function(){ if(!this._check()){ this.fix(); } }, //修复 何问起 fix : function(){ jQuery(':input[placeholder]').each(function(index, element) { var self = $(this), txt = self.attr('placeholder'); self.wrap($('<div></div>').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'})); var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left'); var holder = $('<span></span>').text(txt).css({position:'absolute', left:pos.left, top:pos.top, height:h, lienHeight:h, paddingLeft:paddingleft, color:'#aaa'}).appendTo(self.parent()); self.focusin(function(e) { holder.hide(); }).focusout(function(e) { if(!self.val()){ holder.show(); } }); holder.click(function(e) { holder.hide(); self.focus(); }); }); }};//执行 jQuery(function(){ JPlaceHolder.init(); });
原标题:input placeholder属性IE、360浏览器兼容性问题
关键词:ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。