0

http://jsfiddle.net/h8rxa3pj/2/

$("#open_link").hover(function() {
    $("#menu").removeClass("hidden");
},function() {
    if ($("#menu").is(":hover")) {
        $("#menu").mouseleave(function() {
            $("#menu").addClass("hidden");
        });
    }
    else {
        $("#menu").addClass("hidden");
    };
});

I have looked at the other questions on this and tried pretty much every solution except the ones I couldn't understand.

How do I check if the mouse is over an element in jQuery?

I feel like Arthur's answer could help but I'm really new to jQuery/JS and I don't know how to apply it here. Help appreciated

6
  • Every time you leave #open_link it will register a new mouseleave listener on #menu. That's probably not what you intended.
    – Halcyon
    Commented Jun 15, 2015 at 14:43
  • @Halcyon is that what's making it break? I seriously have no clue.
    – acani
    Commented Jun 15, 2015 at 14:47
  • "Menu should stay as long as it or the link is hovered." - I just tried your jsfiddle and as far as I can see it does as intended, the menu appears and remains if the mouse hovers over the link or menu?
    – smoggers
    Commented Jun 15, 2015 at 14:48
  • @smoggers yes it works in Chrome but in the newest versions of FF and IE the menu won't stay visible when you move your mouse over it from the link
    – acani
    Commented Jun 15, 2015 at 14:50
  • ah yes I see what you mean now, tested in Firefox and yeah it's not working correctly. I've not used much JavaScript/JQuery, so my solution could be improved no doubt, but I've got a simple working solution that works in FF. I'll post it as an answer
    – smoggers
    Commented Jun 15, 2015 at 15:10

1 Answer 1

1
$("#open_link, #menu").hover(function() {
    $("#menu").removeClass("hidden");
});
$("#open_link, #menu").mouseleave(function() {
    $("#menu").addClass("hidden");
});
1
  • Wow thanks so much... I've literally spent hours on this. Can confirm working in FF and IE
    – acani
    Commented Jun 15, 2015 at 15:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.