Reputation: 10649
I have a navigation menu child ul animating when it's parent li is hovered with the mouse. It also slides up when the mouse exits. However, I am trying to get it to delay by 1 second before it slides up. I want the child ul to remain open for 1 second after the mouse leaves. However, it is still sliding up immediately. What's wrong here?
$(".ipro_menu li>ul").hide(); // Hide all
$(".ipro_menu li").mouseenter(function() {
$(this).children("ul").slideDown();
}).mouseleave(function() {
$(this).delay(1000).children("ul").slideUp(); // Wait 1 sec before sliding up
});
Upvotes: 1
Views: 3245
Reputation: 318182
Wrong order, get the elements before you delay the animation, otherwise the delay is applied to this
, not it's children.
$(this).children("ul").delay(1000).slideUp();
Upvotes: 4