Fork: 753 Star: 2230 (更新于 2023-11-14 23:45:40)

license: MIT

Language: HTML.

jQuery contextMenu plugin & polyfill

最后发布版本: 2.9.2 (2020-05-13 22:05:36)

官方网址 GitHub网址

jQuery contextMenu plugin & polyfill

Greenkeeper badge

Travis npm npm CDNJS npm Buy us a tree

$.contextMenu is a management facility for - you guessed it - context menus. It was designed for an application where there are hundreds of elements that may show a context menu - so intialization speed and memory usage are kept fairly small. It also allows to register context menus without providing actual markup, as $.contextMenu generates DOMElements as needed.

features - demo - documentation

Sauce Test Status


  • jQuery >=1.8.2
  • jQuery UI position (optional but recommended)


register contextMenu from javascript:

    // define which elements trigger this menu
    selector: ".with-cool-menu",
    // define the elements of the menu
    items: {
        foo: {name: "Foo", callback: function(key, opt){ alert("Foo!"); }},
        bar: {name: "Bar", callback: function(key, opt){ alert("Bar!") }}
    // there's more, have a look at the demos and docs...

have a look at the demos.

Version 3.0 beta

Version 3.0 is a restructure of the javascript into something more sane written in ES6. It consolidates all API's so callbacks are better documented and more concise. The basics are still the same, but all callbacks are structured differently.

The goal of this refactor was mostly to make the ContextMenu easier to maintain, and make the API's more consise. It also adds JSdoc comments so the API documentation is generated from the code and it enables code completion.

Check out the 3.x branch, or install with npm install jquery-contextmenu@next.

HTML5 Compatibility

Firefox 8 implemented contextmenu using the <menuitem> tags for menu-structure. The specs however state that <command> tags should be used for this purpose. $.contextMenu accepts both.

Firefox 8 does not yet fully implement the contextmenu specification (Ticket #617528). The elements a, button, input and option usable as commands are being ignored altogether. It also doesn't (optically) distinguish between checkbox/radio and regular commands (Bug #705292).

Note: While the specs note <option>s to be renderd as regular commands, $.contextMenu will render an actual <select>. import contextMenu from HTML5 <menu>:


Interaction Principles

You're (obviously) able to use the context menu with your mouse. Once it is opened, you can also use the keyboard to (fully) navigate it.

  • ↑ (up) previous item in list, will skip disabled elements and wrap around
  • ↓ (down) next item in, will skip disabled elements and wrap around
  • → (right) dive into sub-menu
  • ← (left) rise from sub-menu
  • ↵ (return) invoke command
  • ⇥ (tab) next item or input element, will skip disabled elements and wrap around
  • ⇪ ⇥ (shift tab) previous item or input element, will skip disabled elements and wrap around
  • ⎋ (escape) close menu
  • ⌴ (space) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ⇞ (page up) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ⇟ (page down) captured and ignore to avoid page scrolling (for consistency with native menus)
  • ↖ (home) first item in list, will skip disabled elements
  • ↘ (end) last item in list, will skip disabled elements

Besides the obvious, browser also react to alphanumeric key strokes. Hitting r in a context menu will make Firefox (8) reload the page immediately. Chrome selects the option to see infos on the page, Safari selects the option to print the document. Awesome, right? Until trying the same on Windows I did not realize that the browsers were using the access-key for this. I would've preferred typing the first character of something, say "s" for "save" and then iterate through all the commands beginning with s. But that's me - what do I know about UX? Anyways, $.contextMenu now also supports accesskey handling.



$.contextMenu is published under the MIT license

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Special thanks

Font-Awesome icons used from encharm/Font-Awesome-SVG-PNG.

SWIS :heart: Open Source

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.

最近版本更新:(数据更新于2023-11-28 16:47:13)

2020-05-13 22:05:36 2.9.2

2020-05-07 03:09:14 2.9.1

2019-10-13 21:11:02 2.9.0

2019-10-05 16:39:12 2.8.1

2019-01-17 00:02:19 2.8.0

2018-10-02 22:40:48 2.7.1

2018-07-12 17:08:23 2.7.0

2018-03-16 19:24:04 3.0.0-beta.2

2018-03-16 19:17:35 2.6.4

2017-12-31 04:19:44 3.0.0-beta.1


contextmenu, hacktoberfest, html, html5, jquery, jquery-contextmenu, jquery-plugin, polyfill


2023-12-01 14:12:16 mouredev/python-web

2023-11-30 05:48:20 Unstructured-IO/unstructured

2023-11-29 13:33:19 Suffuse-Team/

2023-11-28 10:16:56 web-platform-tests/wpt

2023-11-28 04:36:47 nova-video-player/aos-AVP

2023-11-28 00:41:07 NorthwoodsSoftware/GoJS