//解决ie9及以下版本不支持placeholder属性 $.fn.placeholder = function(options) { var opts = $.extend({}, $.fn.placeholder.defaults, options); var isIE = document.all ? true : false; return this.each(function() { var _this = this, placeholderValue = _this.getAttribute("placeholder"); //缓存默认的placeholder值 if (isIE) { _this.setAttribute("value", placeholderValue); _this.onfocus = function() { $.trim(_this.value) == placeholderValue ? _this.value = "" : ''; }; _this.onblur = function() { $.trim(_this.value) == "" ? _this.value = placeholderValue : ''; }; } }); };
jquery 解决ie9及以下版本不支持placeholder属性
最新推荐文章于 2021-07-23 11:26:25 发布
本文介绍了一种解决IE9及其以下版本浏览器不支持HTML5 placeholder属性的方法。通过使用jQuery扩展函数,为输入框提供了兼容性的解决方案,使得在这些旧版浏览器中也能显示提示文本。
1万+

被折叠的 条评论
为什么被折叠?



