jQuery - 在Internet Explorer中延迟的removeClass上的无效参数

时间:2011-11-16 18:00:24

标签: jquery internet-explorer jquery-ui

我正在使用jQuery 1.7和jQuery UI 1.8.16

我做了一个js小提琴来展示我正在做什么然而它工作正常。它在Internet Explorer中爆炸了。 http://jsfiddle.net/MEDtE/4/

我认为这可能与我对ui-darkness主题的使用有关,但我不明白为什么。

我将问题追溯到jQuery cur函数

cur: function () {
    if (this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null)) {
        return this.elem[this.prop];
    }

    var parsed,
    r = jQuery.css(this.elem, this.prop);
    // Empty strings, null, undefined and "auto" are converted to 0,
    // complex values such as "rotate(1rad)" are returned as is,
    // simple values such as "10px" are parsed to Float.
    return isNaN(parsed = parseFloat(r)) ? !r || r === "auto" ? 0 : r : parsed;
}

backgroundPositionY显然从top调用中获得jQuery.css()的值,并返回该值。

jQuery认为这个值是百分比,并且发生了NaN。

我能解决这个问题吗?

3 个答案:

答案 0 :(得分:1)

我使用setTimeout和浏览器动画获得了混合结果。我会把这一切都保存在jQuery中,并使用jQuery的延迟功能。这应该在所有浏览器中保持相同。

<script>
$(document).ready(function(){
  $('#myp').delay(500).removeClass('ui-state-highlight',1500);
});
</script>

答案 1 :(得分:0)

第二个参数在removeClass中做了什么。 removeClass只需要1个参数。

答案 2 :(得分:0)

这在jQuery 1.7.1中得到了解决 http://bugs.jqueryui.com/ticket/7915

24日出现.... :-P