placeholder 兼容处理
2014-06-27 17:55
197 查看
placeholder是html5 的属性,一些不支持的ie就苦逼了,只能用js处理,代码如下:
可以点击这里研究一下一个比较好的插件(jquery.placehold.js)。
也可以查看这些博客。文章1,文章2
(function($) { $.fn.extend({ placeholder: function() { if ("placeholder" in document.createElement("input")) { return this //如果原生支持placeholder属性,则返回对象本身 } else { return this.each(function() { var _this = $(this); _this.val(_this.attr("placeholder")).focus(function() { if (_this.val() === _this.attr("placeholder")) { _this.val("") } }).blur(function() { if (_this.val().length === 0) { _this.val(_this.attr("placeholder")) } }) }) } } }) })(jQuery);这个不支持密码输入框,还有修改颜色。
可以点击这里研究一下一个比较好的插件(jquery.placehold.js)。
也可以查看这些博客。文章1,文章2
相关文章推荐
- input 的 placeholder属性在IE8下的兼容处理
- placeholder的兼容处理(jQuery下)
- placeholder的兼容处理(jQuery下)
- placeholder 不支持进行兼容处理
- placeholder的兼容处理方法
- 兼容IE8以下浏览器input表单属性placeholder不能智能提示功能,以及使用jquery.validate.js表单验证插件的问题处理
- 对IE8兼容的处理 password框的特殊处理 (placeholder属性)
- HTML5 新增标签兼容处理
- 【css杂记】css兼容处理杂记 1
- Webx框架Velocity上传文件控件不同浏览器显示兼容处理
- 视网膜New iPad与普通分辨率iPad页面的兼容处理
- input表单 disable属性下改变字体颜色 iOS兼容处理
- 单独对IE6兼容进行处理的方法
- 浏览器兼容处理(HTML条件注释、CSSHack和JS识别)
- IE 、Edge、360兼容模式 浏览器背景抖动处理
- 打开Activity页面时,转场动画,打开和退出动画,兼容所有Android系统版本的处理办法
- js+jquery皇帝梦-12 onkeydown以及多种浏览器对事件的兼容处理办法
- HTML一些兼容处理方法
- placeholder兼容IE8解决方案
- 处理Oracle XMLType字段类型不兼容的特殊字符