码迷,mamicode.com
首页 > 其他好文 > 详细

ie下placeholder解决办法

时间:2019-01-24 16:31:41      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:col   tar   code   jquer   ext   nbsp   func   i++   div   

! 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解决办法

标签:col   tar   code   jquer   ext   nbsp   func   i++   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!