简体   繁体   中英

jQuery SlideDown() is not waiting for delay on animation

I use jQuery function that should animate divs (Slide down and up) like a dynamic menu or something.

The problem is even I set up delay() - when mouse goes over it, no matter how long the cursor stays over one div it will slidewon and up.

To clarify. If I put a mouse over the certain div, it works well, it waits the delay and then slide. But if I fast goes over all divs in the example it will make a weird reaction, like the divs start to slide down but then suddenly stops and go up. Try my fiddle and you'll see.

This is the FIDDLE

jQuery(".subdiv").hide();

jQuery(".mydiv").hover(function(){
    jQuery(this).find(".subdiv").stop().delay(800).slideDown("slow");
}, function(){
    jQuery(this).find(".subdiv").stop().delay(200).slideUp("slow");
});

So something like this:

http://jsfiddle.net/GzxJf/12/

jQuery(".subdiv").hide();

jQuery(".mydiv").hover(function(){
    jQuery(".subdiv").each(function() {
        if(jQuery(this).attr('display') !== "none") {
            jQuery(this).stop(true).slideUp("slow");
        }
    });
    jQuery(this).find(".subdiv").slideDown("slow");
}, function(){
    jQuery(this).find(".subdiv").slideUp("slow");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM