YouTip LogoYouTip

Event Contextmenu

# jQuery contextmenu() Method [![Image 4: jQuery Event Methods](#) jQuery Event Methods](#) ## Example Right-click to trigger the contextmenu event
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. | * * * ![Image 5: Example](#) ## More Examples (#) When the paragraph element is triggered, display "Hello World!". (#) Right-click to toggle the background color. * * jQuery Event Methods](#)
← Misc_DataDocker Install Nginx β†’