2014-06-11 69 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很高兴帮助。 –