Custom Context Menu To Improve Web Interactivity – RightMenu.js

Category: Javascript , Menu & Navigation | April 14, 2023
Author:gongpeione
Views Total:315 views
Official Page:Go to website
Last Update:April 14, 2023
License:MIT

Preview:

Custom Context Menu To Improve Web Interactivity – RightMenu.js

Description:

Yet another JavaScript right-click menu plugin designed to create custom context menus within specified areas of your website.

How to use it:

1. Load the required JavaScript and CSS files in the document.

<link rel="stylesheet" href="style.css">
<script src="RightMenu.js"></script>

2. Create an array of menu items as follows:

const myMenu = [
      {
        type: 'link',
        title: 'CSSScript',
        content: 'https://www.cssscript.com/',
        target: '_blank'
      },
      {
        type: 'separator',
      },
      {
        type: 'function',
        title: 'Alert',
        content: () => alert(1)
      },
      {
        type: 'link',
        title: 'Disabled',
        disabled: true
      },
      {
        type: 'text',
        title: 'Plain Text',
        class: 'plain'
      }
]

3. Initialize the RightMenu.js and attach the context menu to the desired element.

new RightMenu('#targetElement', {
    class: 'rightMenu',
    items: myMenu,
});

You Might Be Interested In:


Leave a Reply