jQuery Hover Menu disappears when right click

北慕城南 提交于 2019-12-06 21:15:35

You can "hack" the mouseover/mouseleave behaviour by adding a boolean to check if the context menu is opened into the mouseleave event handler. That's not a really good practice, but it makes your request possible:

var contextMenuOpened = false;

$(document).on('mouseover', '#main_menu', function () {
    $('#main_menu_inner').show();
    contextMenuOpened = false;
});

$(document).on('mouseleave', '#main_menu', function () {
    $("#main_menu").on('contextmenu', function (e) {
        contextMenuOpened = true;
    });
    if (!contextMenuOpened) {
        $('#main_menu_inner').hide();
    }
});

Live exemple

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!