Содержание:
.contextmenu( handler )Возвращает: jQuery
Описание: Bind an event handler to the “contextmenu” JavaScript event, or trigger that event on an element.
-
Добавлен в версии: 1.0.contextmenu( handler )
-
handlerA function to execute each time the event is triggered.
-
-
Добавлен в версии: 1.4.3.contextmenu( [eventData ], handler )
-
eventDataТип: AnythingAn object containing data that will be passed to the event handler.
-
handlerA function to execute each time the event is triggered.
-
-
Добавлен в версии: 1.0.contextmenu()
- This signature does not accept any arguments.
This method is a shortcut for .on( "contextmenu", handler )
in the first two variations, and .trigger( "contextmenu" )
in the third.
The contextmenu
event is sent to an element when the right button of the mouse is clicked on it, but before the context menu is displayed. In case the context menu key is pressed, the event is triggered on the html
element. Any HTML element can receive this event.
For example, consider the HTML:
1
2
3
|
|
The event handler can be bound to the <div>
as follows:
1
2
3
|
|
Now right-clicking on this element displays the alert:
Handler for .contextmenu() called.
To trigger the event manually, call .contextmenu()
without an argument:
1
|
|
Дополнительные замечания:
-
As the
.contextmenu()
method is just a shorthand for.on( "contextmenu", handler )
, detaching is possible using.off( "contextmenu" )
.