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

关于input 属性placeholder 在IE9下兼容

时间:2019-09-13 19:53:24      阅读:68      评论:0      收藏:0      [点我收藏+]

标签:query   ret   his   rip   put   def   理解   ie9   inpu   

今天分享下同事关于input 属性placeholder 在IE9下不兼容的解决方案,小弟不是很懂,希望有看完的大佬说说你们的理解

<script src="http://www.jq22.com/jquery/1.8.3/jquery.min.js"></script>
<script>
(function($){
    $.fn.placeholder = function(options){
        var opts = $.extend({}, $.fn.placeholder.defaults, options);
        var isIE = document.all ? true : false;
        return this.each(function(){
            var _this = this,
                placeholderValue =_this.getAttribute("placeholder"); //缓存默认的placeholder值
            if(isIE){
                _this.setAttribute("value",placeholderValue);
                _this.onfocus = function(){
                    $.trim(_this.value) == placeholderValue ? _this.value = "" : ‘‘;
                };
                _this.onblur = function(){
                    $.trim(_this.value) == "" ? _this.value = placeholderValue : ‘‘;
                };
            }
        });
    };
})(jQuery);
$("input").placeholder();
</script>

求大佬看完后分析下,或等我改天询问到再分享给大伙。

关于input 属性placeholder 在IE9下兼容

标签:query   ret   his   rip   put   def   理解   ie9   inpu   

原文地址:https://www.cnblogs.com/smile-xin/p/11517236.html

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