Trigger right-click

北战南征 提交于 2019-11-28 09:10:20

You can trigger it by

$('#element').trigger({
    type: 'mousedown',
    which: 3
});

http://api.jquery.com/trigger/#example-5

There is a newer way to do this:

$('#element').triggerHandler('contextmenu');

Documentation can be found here.

Similar to this, but I'm not sure if you may be referring to jQuery UI data, but.

$('#element').mousedown(function(event) 
{
    if(event.which == 3)
    {
        if(typeof($(this).data('events')) === 'undefined')
        {
            $(this).data('events', { somedata: 'hello' });
        }
        else
        {
            // "re-throw" right click context menu
        }
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!