2014-06-11 68 views
0

我想知道如何在動畫功能完成後調用第二行?現在第二行在動畫函數完成之前開始。動畫命令完成後的調用命令

有人可以幫助我嗎?對於animate

$(".intro").animate({height:'100%', width:'100%'}, 6000); 
$(".intro").append("<div class='text'>Some Text</div>") 
$(".text").css({"background":"#FFFF00" , "height":"23px","width":"300px","position":"absolute","top":"0","left":"0","bottom":"0","left":"0","margin":"auto"}); 

回答

1

使用回調函數:

$(".intro") 
    .animate(
     {height:'100%',width:'100%'}, 
     6000, 
     function(){ 
      $(".intro").append("<div class='text'>Some Text</div>"); 
     } 
    ); 
3

使用此代碼片段 - 添加的回調。

完整功能:如果提供,則完成回調函數將在動畫完成後觸發。

$(".intro").animate({height:'100%', width:'100%'}, 6000, function(){ 
    $(this).append("<div class='text'>Some Text</div>"); 
}); 

請參閱本Link: .animate()更多的例子。

+0

thans爲您的答案。你幫了我很多:) –

+0

@ kma_999很高興幫助。 –