What is oncontextmenu event in JavaScript?

JavascriptWeb DevelopmentFront End Technology

On right click of an element, when the context menu opens, then it is known as oncontextmenu in JavaScript.


You can try to run the following code to learn how to work with oncontextmenu event in JavaScript −

             function sayHello() {
                alert("You right clicked here.")
      <p oncontextmenu = "sayHello()">Right click</p>
Updated on 19-Jun-2020 11:03:46