解决在ios系统下输入框属性--placeholder--不显示的问题,这个版本不同,会出现。提交下解决方案。
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('');
            }
        });
    });
}如果您有更好方法,请留言,谢谢!






网友评论文明上网理性发言 已有0人参与
发表评论: