简体   繁体   中英

slide down and slide up with different div's

I have a div named first , and another div named second ,both are independent div's.what i need is to be able to slide down div second when the user's mouse hovers over div first,and keep it that way if the user is hovering over div second ,otherwise slide up div second.

$("#first").hover(function(e)
{
    $("#second").slideDown(1000);
},function(e){
    $("#second").slideUp(1000);
});

This is my current code,but it slides up div second ,when i hover over it.

You want to display the div#second even user is hovering over it. So you should also handle hover for div#second too. And additionally you should use .stop() to clear up the animation queue every time before a new animation starts.

Try,

$("#first,#second").hover(function(e)
{
    $("#second").stop().slideDown(1000);
},function(e){
    $("#second").stop().slideUp(1000);
});

DEMO

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