2010-06-02 57 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. 
    }); 
});