其他分享
首页 > 其他分享> > ie7 input 的提示兼容

ie7 input 的提示兼容

作者:互联网

if (!('placeholder' in document.createElement('input'))) {

        $('input[placeholder],textarea[placeholder]').each(function () {
            var that = $(this),
                text = that.attr('placeholder');
            if (that.val() === "") {
                that.val(text).addClass('placeholder');
            }
            that.focus(function () {
                if (that.val() === text) {
                    that.val("").removeClass('placeholder');
                }
            })
                .blur(function () {
                    if (that.val() === "") {
                        that.val(text).addClass('placeholder');
                    }
                })
                .closest('form').submit(function () {
                    if (that.val() === text) {
                        that.val('');
                    }
                });
        });
    }

 

标签:function,val,text,ie7,兼容,input,placeholder,addClass
来源: https://www.cnblogs.com/Ma-YuHao/p/16595199.html