[英]Making jQuery animations in queue
i am trying to do some animations on divs with queue but i kind feel stupid since i cant master it... i made it to queue animations on ONE div but i want it to be done on several divs. 我正在尝试在具有div的div上做一些动画,但是我有点愚蠢,因为我不能熟练掌握它...我让它在一个div上进行动画排队,但是我希望在多个div上完成。
Problem: After clicking on div3-> 问题:单击div3->后
Div1 should become transparent (0.5) Div1应该变得透明(0.5)
after its complete 完成后
Div2 should move right+50px; Div2应该向右移动+ 50px;
after its complete 完成后
Div1 should move top +50px Div1应该移到最上端+ 50px
after its complete 完成后
Div2 should become transparent (0.5) Div2应该变得透明(0.5)
I have the following code but it wont work as expected. 我有以下代码,但无法正常工作。
$("#div3").click(function(){
$("#div1")
.queue(function(next) {
$(this).animate({opacity: 0.5},
{duration: 1000, queue: true});
next();
})
.queue(function(next) {
$("#div2").animate({right: "+=50"},
{duration: 2000})
next();
})
.queue(function(next) {
$(this).animate({top: "+=50"},
{duration: 2000})
next();
})
.queue(function(next) {
$("#div2").animate({opacity: 0.5},
{duration:4000, queue: true});
next();
});
});
Can anyone help me out here? 有人可以帮我从这里出去吗? Thank you in advance
先感谢您
You can try with below code 您可以尝试以下代码
$("#div3").click(function(){
$("#div1").animate({opacity: 0.5},{duration: 1000}, function() {
$("#div2").animate({right: "+=50"},{duration: 2000}, function(){
$("#div1").animate({top: "+=50"},{duration: 2000}, function(){
$("#div2").animate({opacity: 0.5}, {duration:4000});
});
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.