微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery datepicker在IE8中遇到麻烦?

我确实看到了几个类似的线程,但后来他们发现是不同的问题…我的似乎是浏览器特定的问题,因为我的日期选择器在Firefox中工作正常,但肯定不在IE8中.
Here is my original problem and the source code

我将我的datepicker更新为jQuery UI Datepicker 1.8.11 …但它仍然无法在IE 8中运行!弹出日期选择器就好了,但没有事件发生.我是说没有点击……没有任何反应……

有任何想法吗?

解决方法

嘿我不知道你是否已经解决了这个问题,但问题是任何附加的属性.特别是如果你使用:
yearRange: '-100:+10'

例如 …

这是您解决问题的方法:从http://satish.name/?p=19复制

jQuery datepicker在IE中为DOM元素添加一个属性.如果您尝试从现有元素动态复制添加新DOM元素,则datepicker将无法在IE中工作,因为新添加的DOM元素引用旧的jQuery属性.解决此问题的一种方法删除属性,然后在元素上实例化datepicker类.请参阅以下代码获取此修复程序.

//newDiv is the new added dom element with innerHTML
jQuery("#newDiv").find(".datePicker").each(function() {
    //removing jquery added attribute as this is causing the dynamically
    // added DOM elem referring old DOM element from it is copied.
    if (jQuery.browser.msie) {
        var jqaddedattr;
        jQuery(this.attributes).each(function() {
            if (this.name.search(/jQuery/) != -1) {
                jqaddedattr = this;
            }
        });
        if (jqaddedattr) {
            jQuery(this).removeAttr(jqaddedattr.name);
        }
    }
    jQuery(this).datepicker({yearRange: '-100:+10',changeFirstDay:false}).val("").trigger('change');
})

干杯

原文地址:https://www.jb51.cc/jquery/180619.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐