2010-08-28 28 views
2

我正在使用jQuery的animate()函數來動畫div。當我給出多個效果,如高度140和寬度200,然後下一個效果纔開始前面的效果完成。我想同時執行。任何幫助將不勝感激。如何使用jQuery同時動畫多個效果?

代碼:

$(document).ready(function(){ 
    $(".gal_item").hover(function(){      
     $(this).children().animate({height:110},"medium"); 
     $(this).children().animate({width:110},"medium"); 
    }); 
}); 

HTML:

<div class="gal_item"><img src="images/2.jpg" width="120" height="100" /></div> 
<div class="gal_item"><img src="images/3.jpg" width="120" height="100" /></div> 
+1

請發表您的代碼。你應該可以這樣做: $('#id')。animate({width:200px,height:140px},slow) – lnrbob 2010-08-28 07:26:24

+0

我添加了代碼!茲檢查 – Rajasekar 2010-08-28 07:27:08

回答

5

該動畫的方法接受多個樣式聲明,你可以簡單地...

$(document).ready(function(){ 
    $(".gal_item").hover(function(){      
     $(this).children().animate({ 
      height:110, 
      width: 110 
     }, "medium"); 
    }); 
}); 
+0

謝謝mate!,Works Perfect!,+1和tickkk。 – Rajasekar 2010-08-28 07:39:41