IE8'无效参数'在小jQuery动画片段中

IE8 'Invalid argument' in small jQuery animate snippet

本文关键字:动画片 片段 动画 参数 无效 IE8 在小 jQuery      更新时间:2023-09-26

我有一个列表,每次添加一个项目时,最后一个项目都应该被删除。我已经让它在Chrome和Firefox中运行良好,但IE拒绝了。

不确定原因,但IE8在某个时刻抛出了Invalid参数错误。我相信我已经追踪到了这一部分,但我不知道在哪里,也不知道为什么。万一错误实际上超出了这一部分,您可以在这里看到一个更完整的、可工作(或不可在IE8中工作)的版本。

first.animate({top:0}, 250, function() {
    first.animate({marginTop: oldMarginTop}, 500, function() {
        last.animate({top: olPaddingBottom}, 125, function() {
            //Remove the old element
            last.remove();
            //Reset the CSS we changed
            stream.css({
                height: 'auto',
                overflowY: 'visible'
            });
        });
    });
});

第一个和最后一个是从列表中选择的节点。第一个是新创建的列表项,最后一个是我们将要删除的列表项。

使用而不是oldMarginTop。。。。

parseInt(0+oldMarginTop,10)

对我来说,IE为oldMarginTop返回"auto",该值无法设置动画,您需要一个数值(如果不是数值,建议将该值设置为0)

http://jsbin.com/uvepit/