English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery contextmenu() Method

jQuery Events

The contextmenu() method triggers the contextmenu event, or attaches a function to be executed when the contextmenu event occurs.

The contextmenu event occurs when the user right-clicks on an element to open the right-click menu.

Syntax:

Trigger the contextmenu event of the selected element:

$.contextmenu()

Attach a function to the contextmenu event:

$.contextmenu(function

Instance

Change the font size of the paragraph on the page when right-clicked:

$("p").contextmenu(function(){
  $(this).css("font-size", "3em");
});
Test and see‹/›

Hide the paragraph on the page when right-clicked:

$("p").contextmenu(function(){
  $(this).slideUp();
});
Test and see‹/›

Parameter Value

ParametersDescription
functionFunction executed when the contextmenu event is triggered

jQuery Events