开发者

How to capture a right clicking on a select box option with jQuery?

I am looking for an easy way to select an option from a select list and be able to perform a number of actions on that option. One of the main operations is to edit the option. I would like to implement a context type menu by right clicking the option and then perform the action.

Does anyone know how to capture a 开发者_运维技巧right click on a select box option with jQuery?

I would like to use: http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/

Thanks!!!


The event has a "which" property that hols the "id" of the button pressed. You should use it with the "mousedown" event to prevent the browser's context menu to appear.

$("#selectBoxID").mousedown(function(e) {
    if (e.which == 1) {
        /*  left click action */
    }
    else if (e.which == 2) {
        /*  middle click action */
    }
    else if (e.which == 3) {
        /*  right click action */
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜