2010-03-25 89 views
1

我有下面的代碼,它工作正常,可以通過示例查看。一旦用戶將鼠標懸停在一個菜單上,除非頁面被刷新,否則您不能將鼠標懸停在其上。我有一種感覺,它與我的隊列有關,我試過.stop(),但似乎沒有工作。jquery清除動畫隊列

<script type="text/javascript"> 
    $(document).ready(function() 
    { 


     $('li').hover(function() 
     { 

        $(this).children("p.subtext").stop().slideDown();    




      }, 

       function() 
       { 

       $(this).children("p.subtext").stop().animate({height:'0px'},{queue:false, duration:600, easing: 'easeOutBounce'}) 

     }); 





    }); 
    </script> 

乾杯

回答

10

在這種情況下,使用.stop(true, true)

在停止這第一個參數指示它來清除隊列,see here for more info on .stop()

編輯,爲您的隊列問題:

$('li').hover(function() { 
    $(this).children("p.subtext").slideDown();    
}, function() { 
    $(this).children("p.subtext") 
     .animate({height:'toggle'},{duration:600, easing: 'easeOutBounce'}); 
}); 
+0

謝謝忘了說我試過了,它沒有任何區別。 – Elliott 2010-03-25 13:42:36

+0

@Elliott - 您正在爲'0px'高度設置動畫,並將其保留在0像素高處......所以沒有什麼可以向左擴展的,請嘗試將'0px'更改爲'toggle' – 2010-03-25 13:45:13

+0

Argh正確,這是有效的,但僅適用對於菜單中的一個項目,您可以在上面的鏈接中看到它。再次感謝編輯 - 一旦你徘徊在他們幾次,他們似乎停止工作。 – Elliott 2010-03-25 13:47:04