2013-01-14 99 views
1

我有一個函數,當運行時,在我的頁面上動畫一個div並刪除一個類,然而我想要做的是在高度動畫結束時刪除類,這可能與jQuery?命令jquery函數在另一個函數完成後發生

 var el = $(this).find('ul li'); 
     var img = $(this).find('ul li img');   
     $(this).removeClass('active'); 

     //return false; 
     el.animate({height:'135px'}, 500); 
     el.css({ 
      'background-position':'top left', 
      'background-size' : 'auto auto' 
     });    


     $(this).find('ul li img').animate({height:'270px'}, 500); 
     $(this).animate({height:'135px'}, 500); 

     img.attr('src', function(i, value) { 
      return value.substring(28); 
     }); 
+0

使用動畫回調函數,設置你的邏輯有 –

回答

3

有一個complete函數在動畫完成後運行。按照jQuery docs for the animate function,你可以使用它像這樣:

el.animate({height:'135px'}, 500, function() { 
    //code to run when complete goes here 
}); 
0

使用完整的呼叫這樣的.animate函數內部:

相關問題