1

我认为这与在不同范围内运行的函数有关,在该范围内无法访问 jquery 库(显示为下面第二行的最后一个参数)

var funcExpandHeight = container.animate({
    height: '300px'
}, 300, function () {});
foo.animate({
    height: 'show'
}, 300, funcExpandHeight);

第一行有效,然后崩溃'f.easing[i.animatedProperties[this.prop]] is not a function'

如下图所示,将这些线组合在一起,操作成功完成。

    foo.animate({
     height: 'show'
 }, 300, function () {
     container.animate({
         height: container[0].scrollHeight + 'px'
     }, 300, function () {})
 });
4

1 回答 1

3

第三个参数.animate()是回调函数,但在您的第一个代码中,您只是传递了一个变量。

var funcExpandHeight = function() {
   container.animate({height: '300px'}, 300, function(){});
}
foo.animate({height: 'show'}, 300, funcExpandHeight);

笔记

的配置.animate()如下:

.animate( properties [, duration] [, easing] [, complete] )

where[]表示可选。

在您的代码中,您没有给出easingso,第三个参数将被视为完整的回调函数。

有关更多详细信息,请参见上面的链接。

于 2012-06-13T09:51:27.863 回答