jquery清除动画队列

问题描述:

我有下面的代码,它工作正常,可以通过示例查看。一旦用户将鼠标悬停在一个菜单上,除非页面被刷新,否则您不能将鼠标悬停在其上。我有一种感觉,它与我的队列有关,我试过.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> 

干杯

在这种情况下,使用.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