placeholder 兼容IE
来源:互联网 发布:百慕达网络超市招聘 编辑:程序博客网 时间:2024/06/05 04:56
placeholder 是html5的新属性,所有只有支持html5的浏览器才能解析placeholder属性,下面介绍一种placeholder兼容IE浏览器的方法,
JS:jquery.JPlaceholder
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();
});
页面调用:
<script src="~/JsScript/Web/Common/jquery.JPlaceholder.js"></script>
<input id="username" name="username" placeholder="Please The Name " type="text" />
- 兼容IE的placeholder
- placeholder兼容ie
- placeholder 兼容IE
- placeholder兼容ie
- 使IE兼容placeholder属性
- IE兼容-placeholder的方法
- html5 placeholder ie版本兼容
- html5兼容IE placeholder问题
- placeholder兼容ie和password
- Html5的placeholder属性(IE兼容)
- placeholder在ie浏览器的兼容
- 实现ie浏览器对placeholder的兼容
- jQuery实现IE浏览器兼容placeholder效果
- IE兼容实现HTML5的placeholder
- IE不兼容placeholder的解决方案
- 实现IE浏览器兼容placeholder效果
- 【转】placeholder属性模拟插件(兼容IE)
- html5的placeholder属性(IE如何兼容placeholder属性)
- 编写让别人能读懂的代码
- Fragment 嵌套 Fragment 首次加载没问题,第二次加载子Fragment出现问题
- 事务总结
- 分页sql语句
- UI基础控件系列---->UITextField
- placeholder 兼容IE
- Java获取键盘输入
- 代码签名
- Git总结
- Xcode移除项目中的CocoaPods
- 继承与接口---覆盖、虚继承
- opencv imwrite 可以保存,imshow没有显示
- 分享一个 ios 自动适配的资料
- 正则表达式大全