如何使用 jQuery 为多个元素按顺序制作动画? [英] How can I animate multiple elements sequentially using jQuery?
本文介绍了如何使用 jQuery 为多个元素按顺序制作动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为这很简单,但我仍然无法让它工作.通过单击一个按钮,我希望发生多个动画 - 一个接一个 - 但现在所有动画都同时发生.这是我的代码 - 有人可以告诉我哪里出错了吗?:
I thought it would be simple but I still can't get it to work. By clicking one button, I want several animations to happen - one after the other - but now all the animations are happening at once. Here's my code - can someone please tell me where I'm going wrong?:
$(".button").click(function(){
$("#header").animate({top: "-50"}, "slow")
$("#something").animate({height: "hide"}, "slow")
$("ul#menu").animate({top: "20", left: "0"}, "slow")
$(".trigger").animate({height: "show", top: "110", left: "0"}, "slow");
});
推荐答案
你可以做一堆回调.
$(".button").click(function(){
$("#header").animate({top: "-50"}, "slow", function() {
$("#something").animate({height: "hide"}, "slow", function() {
$("ul#menu").animate({top: "20", left: "0"}, "slow", function() {
$(".trigger").animate({height: "show", top: "110", left: "0"}, "slow");
});
});
});
});
这篇关于如何使用 jQuery 为多个元素按顺序制作动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文