tags:

views:

515

answers:

1

I have the code below, which works fine it can be viewed here for an example. Once the user hovers over one menu, you can then not hover over it again unless the page is refreshed. I have a feeling its something to do with my queue and I have tried .stop() but doesnt seem to work.

<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> 

Cheers

+3  A: 

In this case, use .stop(true, true)

This first parameter in stop instructs it to clear the queue, see here for more info on .stop()

Edit, for your queue issue:

$('li').hover(function() { 
  $(this).children("p.subtext").slideDown();            
}, function() { 
  $(this).children("p.subtext")
         .animate({height:'toggle'},{duration:600, easing: 'easeOutBounce'});
}); 
Nick Craver
Thanks forgot to say I tried that and it hasnt made any difference.
Elliott
@Elliott - You're animating to `0px` height, which leaves it at 0 pixels high...so there's nothing to expand left, try changing that `0px` to `toggle`
Nick Craver
Argh right, that works but only works for one item in the menu, you can see it on the link above. Thanks again EDIT - Once you hover over them all a few times, they seem to stop working.
Elliott
@Elliott - This is a result of the height being cut off mid-animation with stop and `queue:false`, remove that to get rid of the hiding, updated the answer with the full code.
Nick Craver
Thanks that works great, I just had to add in .stop() so it doesnt mess up when u hover over it millions of times.Thanks alot :)
Elliott