Here you can see that the alert is executed just before the context menu. To disable the menu, you can add “return false”.
How to get clicked element and do operations on them?
By using event.target you can get the target element where the right click is done. You need to pass an argument in the context menu function, this argument will be the event object. From the event object, you can access the target element.
Here is an example :
2. Using the mousedown event. we can handle any mouse button click with the mouse-down event. For example, execute the following: