如何同时运行两个 jQuery 动画? [英] How to run two jQuery animations simultaneously?
本文介绍了如何同时运行两个 jQuery 动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以同时在两个不同的元素上运行两个动画?我需要这个问题的反面 Jquery queuing animations.
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屋!
查看全文