2010-06-02 65 views
0
$(".menu-container").animate({top:"25px"}); 
$(".menu-container").animate({top:"-900px"}); 
$(".windows-container").animate({top:"-730px"}); 

先生您好..我在jQuery的队列中有一个问题..我想要做的是jQuery的排队问题

$(".menu-container").animate({top:"25px"}); ----execute first then after this, 

$(".menu-container").animate({top:"-900px"});   --this one and 
$(".windows-container").animate({top:"-730px"});  --this one should execute at the same time.. 

我试过,但它不能正常工作..

$(".menu-container").queue(function(){ 
    $(".menu-container").animate({top:"25px"}); 
    $(".windows-container").animate({top:"-730px"}); 
    $(".menu-container").animate({top:"-900px"}); 
}); 

+0

我认为最后两行不执行到执行的操作的回调函数..我还没有看到。菜单容器并没有设置动画顶部:0px; – 2010-06-02 17:16:09

回答

4

您需要时,前一个结束,这样启动每个动画:

$(".menu-container").animate({top:"25px"}, function() { 
    $(".menu-container").animate({top:"-900px"}, function() { 
     $(".windows-container").animate({top:"-730px"}); 
    }); 
}); 
+0

我试过这个.. $(“。menu-container”)。animate({top:“25px”},function(){(“。menu-container”)。animate({top:“ - 900px“}); $(”。windows-container“)。animate({top:” - 730px“}); }); 它的作品..谢谢你们..非常感谢你.. :) – 2010-06-02 17:04:08

1

有生有可以使用后的动画完成

$('#clickme').click(function() { 
    $('#book').animate({ 
    opacity: 0.25, 
    left: '+=50', 
    height: 'toggle' 
    }, 5000, function() { 
    // Animation complete. 
    }); 
});