The left mouse Click event is what we often encounter, then, how to write a mouse right click event?
Usually, the mouse has three keys: Left (1), Middle key (2), right (3), jquery through E.which can determine which button clicked, if not through E.which judgment, the default click the left mouse button. For example:
$ ('. Btn '). MouseDown (function (e) { if (3 = = E.which) { alert (' This is a right-click event '); } else if (1 = = E.which) { alert (' This is a left-click event '), } else{ alert (' This is a middle-click event ');} )
The browser will have a default right mouse button event: Pop Up a menu bar (bad, just press the shortcut key, the menu disappears ...) At this point, if you want to pop up our custom menu bar, we'll block the default right-click event.
$ (document). Ready (function () { $ (document). Unbind ("ContextMenu"). Bind ("ContextMenu", function (e) { return false; }); If you want to restore the mouse right-click event, simply change the return false to true.
Mouse Right-click event