This time I will share jQuery Plugin and tutorial about Easy Customizable jQuery Context Menu Plugin – Our Context Menu, hope it will help you in programming stack.
Our Context Menu is a jQuery plugin which helps you bind a customizable and themeable context menu to the right click event within a specific container.
How to use it:
1. Load a theme CSS of your choice into the document’s head
section.
01 |
< link href = "dist/css/ourcontextmenu.cosmo.css" rel = "stylesheet" > |
03 |
< link href = "dist/css/ourcontextmenu.darkly.css" rel = "stylesheet" > |
05 |
< link href = "dist/css/ourcontextmenu.default.css" rel = "stylesheet" > |
07 |
< link href = "dist/css/ourcontextmenu.flatly.css" rel = "stylesheet" > |
09 |
< link href = "dist/css/ourcontextmenu.superhero.css" rel = "stylesheet" > |
11 |
< link href = "dist/css/ourcontextmenu.youtube.css" rel = "stylesheet" > |
2. Create the context menu from an html unordered list and used html5 data-value
to specify the value for each option.
1 |
< ul class = "our-context-menu" id = "context-menu" > |
2 |
< li data-option = "0" >Home</ li > |
3 |
< li data-option = "1" >Lorem ipsum dolor sit amet</ li > |
4 |
< li data-option = "2" >Lorem ipsum dolor sit amet</ li > |
5 |
< li data-option = "3" >Lorem ipsum dolor sit amet</ li > |
6 |
< li data-option = "4" >Lorem ipsum dolor sit amet</ li > |
3. Load jQuery library and the jQuery Our Context Menu plugin at the end of the document to improvde the page load speed.
1 |
<script src= "//code.jquery.com/jquery-1.12.1.min.js" ></script> |
2 |
<script src= "dist/js/ourcontextmenu.js" ></script> |
4. Initialize the plugin and specify the container in which the context menu should be displayed.
2 |
target: $( '#target-container' ), |
4 |
$( '#context-menu' ).ourcontextmenu(settings); |
5. More plugin settings.
03 |
target: $( '#target-container' ), |
11 |
onAction: function (){}, |
14 |
beforeShown: function (){}, |
21 |
$( '#context-menu' ).ourcontextmenu(settings); |
6. You can also create your own themes like this:
05 |
.our-context-menu li { |
09 |
.our-context-menu li:hover { |
This awesome jQuery plugin is developed by sdkcarlos. For more Advanced Usages, please check the demo page or visit the official website.