Pure JavaScript Context Menu Plugin ContextMenu.js

Category: Javascript , Menu & Navigation | July 21, 2017
Author: wbwiltshire
Views Total: 1,411
Official Page: Go to website
Last Update: July 21, 2017
License: MIT

Preview:

Pure JavaScript Context Menu Plugin ContextMenu.js

Description:

ContextMenu.js is a vanilla JavaScript plugin that adds a simple right click context menu to any container without the need of any 3rd JS libraries.

How to use it:

Load the required stylesheet contextMenu.css that contains the primary CSS styles for the context menu.

<link href="contextMenu.css" rel="stylesheet">

Add the CSS class ‘contextMenu-target’ to any container you want to display the context menu.

<tr id='2' class='contextMenu-target'>
  <td>2</td>
  <td>Darth</td>
  <td>Vader</td>
  <td>[email protected]</td>
</tr>

Load the JavaScript file ‘contextMenu.js’ at the end of the document.

<script src="contextMenu.js"></script>

Initialize the plugin and you’re done.

document.addEventListener("DOMContentLoaded", function (event) {
  contextmenu = new ContextMenu();
});

Leave a Reply