解决ie8不兼容占位符的问题

来源:互联网 发布:淘宝vip会员卡素材 编辑:程序博客网 时间:2024/05/19 18:44
// IE placeholder(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);    $('.gInput1,.gInput2,.fInput').placeholder();    这里的类名就是input的类名。
阅读全文
0 0