JQuery.slideUp () issue
Can someone tell me why the Effect works so often, hover. I mean, you are hooking 3 times without waiting for the effect to finish, and you can wait until the effect has worked 3 times.
$(function() {
$('#dropdown_nav li').find('.sub_nav').hide();
$('#dropdown_nav li').hover(function() {
$(this).find('.sub_nav').slideDown(300);
}, function() {
$(this).find('.sub_nav').delay(2000).slideUp(300);
});
});
It can be tested here: http://jsfiddle.net/QTGvJ/
+3
source to share
1 answer
Usage .stop()
will clear animation queues
$('#dropdown_nav li').on('mouseenter mouseleave',function() {
$('.sub_nav', this).stop().slideToggle();
});
With mouse delay:
$('#dropdown_nav li').on('mouseenter mouseleave',function( e ) {
var delayTime = e.type=='mouseleave' ? 1000 : 0;
$('.sub_nav', this).stop().delay( delayTime ).slideToggle();
});
Find out more: http://api.jquery.com/stop/
+5
source to share