2011-09-27 104 views
2

我在jQuery中使用動畫。我遇到問題執行動畫。它的測試功能後執行我想之前的測試功能jQuery的動畫幫助需要

$('.next').live('click',function() { 
        $('.ac_bgimage').animate({ 
         left:"-100em"  
        }, 15000); 
        test(); 
       }); 

運行這一點,但現在,當我上隔壁班的點擊我的測試功能首先執行,我想動畫的執行後,執行以後。

回答

3

試圖把它變成回調函數

$('.next').live('click',function() { 
     $('.ac_bgimage').animate({ 
      left:"-100em"  
     }, 15000 , function(){ 
      test(); 
     });     
    }); 
+0

你不需要包裝測試功能到另一個anonymouse恕我直言 –

+0

@JanPfeifer:是的,我需要的時候OP希望在動畫完成後調用test() – genesis

+0

不,它仍然先執行test()函數 –

0

這應該工作:

$('.next').live('click',function() { 
       $('.ac_bgimage').animate({ 
        left:"-100em"  
       }, 15000, function() { test();}); 
      }); 
+0

不,它還是先執行test()函數 –