Home >Web Front-end >JS Tutorial >jquery implements right-click menu plug-in_jquery
Today when developing a project, I need a function that simulates the mouse right-click menu. That is to say, when you right-click the mouse on the web page, it is not the system menu that pops up but the content we have formulated. This can expand the functions of the right click. Not much to say about the implementation process. The code and effects are as follows:
js part:
The css part of the code is as follows:
Create the calling code as follows:
The destruction call code is as follows:
The effect is as follows:
Calling instructions:
Create: epMenu.create(point,option);
point is an integer type, indicating the position of the menu, relative to the upper left corner of the browser.
Example: {left:100, top:500}
option json array type, represents the menu item, name represents the name, and action represents the action triggered by the click.
Example: [{name:'a1','action':addText},{name:'b222','action':addBtn},{name:'Add Image Component','action':addImage}]
Destruction: epMenu.destory();
Destruction requires no parameters.
This thing is actually very simple! It can also be expanded, such as adding pictures, secondary menus, etc. Since the development requirements of this project are relatively simple, that’s it.
The above is the entire content of this article, I hope you all like it.