高级右键单击功能 - 单击并按住,显示按钮,在发布时单击悬停的内容

时间:2012-10-24 22:26:49

标签: javascript jquery mouse

你会如何在javascript / jquery中执行此操作?

我目前有right-click + hold显示div,然后在右键单击发布时消失。但是,我想点击右键单击释放鼠标悬停的任何按钮。

这是我到目前为止所做的:

// Cancel out the default context menu
$('body').on('contextmenu', function(){
    return false;
});

$("body").on('mousedown', function(event){
    // If it's not a right click, return
    if (event.which != 3) 
        return;

    // Set div coordinates to clicked point
    $('div').css({
        'top': event.pageY,
        'left': event.pageX
    });

    $('div').show();
});    

$("body").on('mouseup', function(event){
    // If it's not a right click, return
    if (event.which != 3)
        return;

    $('div').hide();
});

1 个答案:

答案 0 :(得分:1)

尝试将mouseup事件处理程序附加到按钮。