0

i have this simple example here : http://jsfiddle.net/pTyvc/1/ i don't want the sub_menu div to slideUp if mouse is over it any help ? thanks

6
  • It doesn't collapse for me. Perhaps your browser doesn't like you. Commented Feb 15, 2012 at 14:12
  • he means if you move to the blue block. it does it for me too. Commented Feb 15, 2012 at 14:17
  • Oops sorry, it doesn't like me either :) Commented Feb 15, 2012 at 14:19
  • Its because of the mouseleave event. Commented Feb 15, 2012 at 14:26
  • ya it's because the mouseleave so how to keep it showing till the sub_menu mouseleave Commented Feb 15, 2012 at 14:36

1 Answer 1

1

You'll have to use mouseover because mouseenter is not fired when you move from a child element to the parent element.

Also, when you mouseover a sub menu, you'll have to .stop() the animation to keep it from sliding up. The same applies for moving the mouse from the sub menu to the parent element.

http://jsfiddle.net/pTyvc/25/

$(".menu_item").mouseover(function(){ $(this).addClass("selected") .children().stop().slideDown(500); }); $(".menu_item").mouseout(function(e){ $(this).removeClass("selected") .children(".sub_menu").slideUp(500); }); $(".sub_menu").mouseover(function() { $(this).stop(); }); 
Sign up to request clarification or add additional context in comments.

4 Comments

@Yasser: I see it actually starts acting weird if you move the mouseover the sub menu when it's sliding down. This seems a bit complicated.
Add '.animate({height:'100px'});' after 'stop()' in order the div will continue to slide down to the full height
@Hadas: Thanks, though it makes for some delay when hovering now.
@pimvdb Sure,it stop and only then animate

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.