首页 > 其他 > 详细

ie下placeholder解决办法

时间:2019-01-24 15:58:12      阅读:168      评论:0      收藏:0      [点我收藏+]
! function(window, document, $, undefined) {
    var target, i = 0,
        len, tmpPh;
    if (‘placeholder‘ in document.createElement(‘input‘)) return;
    target = $(‘[placeholder]‘);
    for (len = target.length; i < len; i++) {
        tmpPh = target[i].getAttribute(‘placeholder‘);
        target[i].value = tmpPh;
        target[i].style.color = ‘#aaaaaa‘;
        target[i].onmouseover = function() {
            if (this.value != this.getAttribute(‘placeholder‘)) return;
            this.value = ‘‘;
            this.style.color = ‘#000000‘;
        }
        target[i].onblur = function() {
            if (this.value != ‘‘) return;
            this.value = this.getAttribute(‘placeholder‘);
            this.style.color = ‘#aaaaaa‘;
        }
    }
}(window, document, jQuery); 

 

<input type="text" placeholder="请输入你的名字">
<hr>
<input type="text" placeholder="aaa">
<hr>
<input type="text" placeholder="bbb">

 

ie下placeholder解决办法

原文:https://www.cnblogs.com/sharing1986687846/p/10314851.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!