-1

I am looking for a jQuery selector that has an 'either' selection. The thing is, I have a dropdown menu and want them to leave on 2 options.

Either when they leave the button or when they leave the menu that popped out.

When I use jQuery(".button, ul.menu").mouseleave it will dissapear when I leave the button.

I want it to be different; at least 1 of the selectors HAS to be hovered to have the menu out.

How would I be able to do this?

<script>
jQuery(document).ready(function(){
  jQuery(".button").mouseover(function(){
    jQuery("ul.menu").stop().delay(600).fadeIn("fast");
  });
  jQuery("ul.menu, .button").mouseleave(function(){
    jQuery("ul.menu").stop().fadeOut("fast");
  });
});
</script>

Thanks!

dda
  • 6,030
  • 2
  • 25
  • 34

1 Answers1

0

I can't see your HTML markup, but you wrap the two elements in a container like and handle the mouseleave on it, it will be fired she you leave the container; like:

jQuery(document).ready(function(){
    jQuery(".button").mouseover(function(){
        jQuery("ul.menu").stop().delay(600).fadeIn("fast");
    });
    jQuery(".container").mouseleave(function(){
        jQuery("ul.menu").stop().fadeOut("fast");
    });
});
Irvin Dominin
  • 30,819
  • 9
  • 77
  • 111