Right-click here
$(function(){ $("#target").contextmenu(function(){alert("Handler for .contextmenu() called."); }); })
[Try it Β»](#)
* * *
## Definition and Usage
The `contextmenu()` function is used to add an event handler to the `contextmenu` event.
**Note:** The `.contextmenu()` method is just a shorthand for `.on( "contextmenu", handler )`. To remove the event, use `.off( "contextmenu" )`.
## Syntax
`$(selector).contextmenu( , handler )`
| Parameter | Description |
| :--- | :--- |
| _eventData_ | Optional. Any type. An object of data passed to the event handler. |
| _handler_ | Optional. Function type. The function to run when the event is triggered. |
* * *

## More Examples
(#)
When the paragraph element is triggered, display "Hello World!".
(#)
Right-click to toggle the background color.
* * jQuery Event Methods](#)Event Contextmenu
# jQuery contextmenu() Method
[ jQuery Event Methods](#)
## Example
Right-click to trigger the contextmenu event
YouTip