ie下placeholder解决办法
Posted sharing1986687846
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ie下placeholder解决办法相关的知识,希望对你有一定的参考价值。
! 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解决办法的主要内容,如果未能解决你的问题,请参考以下文章
使用jQuery快速解决input中placeholder值在ie中无法支持的问题