How to make multiple jQuery animations run at the same time?

Ale*_*dro 8 jquery jquery-animate

As it stands there us a difference between the two and I want them to run at the same time. Here is the code:

$(selector1).animate({
    height: '670'
}, 2000, function() {
    // Animation complete.  
});

$(selector2).animate({
    top: '670'
}, 2000, function() {
    // Animation complete.
});?
Run Code Online (Sandbox Code Playgroud)

and*_*lrc 21

queue:false.您可以在此处查看完整的文档.

$(selector1).animate({
    height: '670'
}, {
    duration: 2000,
    queue: false,
    complete: function() { /* Animation complete */ }
});

$(selector2).animate({
    top: '670'
}, {
    duration: 2000,
    queue: false,
    complete: function() { /* Animation complete */ }
});
Run Code Online (Sandbox Code Playgroud)

文档:

.animate(properties,options) 版本已添加:1.0


properties动画将移向的CSS 属性的映射.
options要传递给方法的其他选项的映射.支持的键:
duration:确定动画运行时间的字符串或数字.
easing:一个字符串,指示要用于转换的缓动函数.
complete:动画完成后调用的函数.
step:在动画的每个步骤之后调用的函数.
queue:一个布尔值,指示是否将动画放置在效果队列中.如果为false,则动画将立即开始.从jQuery 1.7开始,queue选项也可以接受一个字符串,在这种情况下,动画会被添加到该字符串所代表的队列中.
specialEasing: 由properties参数定义的一个或多个CSS属性及其相应的缓动函数的映射(添加1.4).

  • 对你来说可能很简单/清楚,但每个人都有不同的专业领域.复制大量文档(大部分与此答案无关)并没有那么有用,因为你还没有真正解释`queue`的作用.没有任何迹象表明OP尚未阅读文档,仍然想提出问题. (3认同)