如何同时运行两个jQuery的动画? [英] How to run two jQuery animations simultaneously?

查看:185
本文介绍了如何同时运行两个jQuery的动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在两个不同的元素同时运行两个动画?我需要这个问题 jQuery的排队动画的是相反的。

Is it possible to run two animations on two different elements simultaneously? I need the opposite of this question Jquery queueing animations.

我需要做这样的事情...

I need to do something like this...

$('#first').animate({ width: 200 }, 200);
$('#second').animate({ width: 600 }, 200);

,但在同一时间运行这两个。我能想到的会使用的唯一的事情的setTimeout 每进行一次动画,但我不认为这是最好的解决办法。

but to run those two at the same time. The only thing I could think of would be using setTimeout once for each animation, but I don't think it is the best solution.

推荐答案

是的,有!

$(function () {
    $("#first").animate({
       width: '200px'
    }, { duration: 200, queue: false });
    $("#second").animate({
       width: '600px'
    }, { duration: 200, queue: false });
});

这篇关于如何同时运行两个jQuery的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆