placeholder技能在IE中损坏的解决方式转载
原创
* {
margin:0;
padding:0;
border:0;
}
*,*:after,*:before {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
input {
display:block;
margin:20px auto;
width:500px;
height:50px;
border:2px solid #ccc;
padding:0 20px;
}
;(function($) {
$.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);
$("input").placeholder();
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
上一篇:鼠标定位div实时显示 下一篇:幻灯片切换