让IE支持placeholder属性,兼容IE6,7,8,9
来源:互联网 发布:sql sa默认密码 编辑:程序博客网 时间:2024/06/04 18:12
1.[JavaScript]代码
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()); if(self.val() != ''){ holder.hide(); } self.keyup(function(e){ if(self.val() == ''){ holder.show(); }else{ holder.hide(); } }); holder.click(function(e) { holder.hide(); self.focus(); }); }); }};//执行jQuery(function(){ JPlaceHolder.init(); });
原地址 http://www.oschina.net/code/snippet_206691_26471
0 0
- 让IE支持placeholder属性,兼容IE6,7,8,9
- 让IE支持placeholder属性
- 让IE支持placeholder属性
- 让IE支持placeholder属性
- 让IE支持placeholder属性~
- 让IE支持placeholder属性
- 兼容其他不支持placeholder的浏览器(超强的让IE下支持placeholder的属性插件)
- placeholder 兼容 ie6/7/8/9
- Jquery实现IE6 7 8 兼容placeholder属性
- html5 Placeholder属性兼容IE6、7方法
- HTML5属性placeholder,支持IE6、7、8浏览器
- 让ie6,7,8支持css3属性
- 使IE兼容placeholder属性
- IE6,7,8,9中H5属性placeholder不兼容问题
- html5的placeholder属性(IE如何兼容placeholder属性)
- Html5的placeholder属性(IE兼容)
- 【转】placeholder属性模拟插件(兼容IE)
- 让ie6,7,8支持css3的一些属性
- 记录自己成长和学习
- 使用VMWARE9.0安装xp ghost盘后启动提示找不到操作系统
- hdu5396 2015多校第九场 区间dp
- 日经春秋 20150819
- ubuntu安装shiny-server记录
- 让IE支持placeholder属性,兼容IE6,7,8,9
- jQuery--品牌展示
- 左值、右值与右值引用
- 关于盒子二三事
- java list三种遍历方法性能比较
- noip2002—选数
- 黑马程序员-----C语言学习之流程控制
- Android 退出整个应用程序
- 操作系统学习笔记