Latest web development tutorials

jQuery contextmenu () method

jQuery Event Methods jQuery Event Methods

Examples

Right-click contextmenu event trigger

<Div id = "target"> Right-click here </ div> <script> $ (function () {$ ( "#target" ). Contextmenu (function () { alert ( "Handler .contextmenu () is called." );});}) < / Script>

try it"

Definition and Usage

contextmenu () function is used to add an event handler to the contextmenu event.

Note: .contextmenu () method just as .on ( "contextmenu", handler) is a shorthand wording, can be used to remove the event .off ( "contextmenu").


grammar

$(selector).contextmenu( [eventData ], handler )

参数 描述
eventData 可选。 任意类型 传递给事件处理程序的参数对象。
handler 可选。 Function类型 事件触发时执行的函数。


Examples

More examples

Right-click on the pop-up tips
When the paragraph element is triggered, the display "Hello World!".

Right-click the Change background colors
Right-click to switch the background color.


jQuery Event Methods jQuery Event Methods