首页 > 其他 > 详细

关于input 属性placeholder 在IE9下兼容

时间:2019-09-13 19:01:04      阅读:66      评论:0      收藏:0      [点我收藏+]

今天分享下同事关于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下兼容

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

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