.contextmenu() methodThe .contextmenu() method in jQuery is used to bind an event handler to the contextmenu event on the element
or trigger an contextmenu event on an element.
.contextmenu() method Syntax.contextmenu() .contextmenu(handler) .contextmenu(eventData,handler)
| Parameter | Type | Description |
|---|---|---|
handler |
Function | A function to execute when the contextmenu is triggered on the matched element.return false to prevent the default right click action. |
eventData |
Anything | Additional data passed to the event handler. |
.contextmenu() method ExampleCall .contextmenu() without an argument will trigger a contextmenu event.
Trigger the contextmenu event on all paragraphs:
$("p").contextmenu();
.contextmenu([eventData,]handler) method ExampleRight click to toggle background color.
$("#block").contextmenu( function () {
$(this).toggleClass( "highlight" );
// return `false` to prevent the default right click action
return false;
}); Date:2019-08-29 23:58:20 From:www.Lautturi.com author:Lautturi
