ondblclick

The oncontextmenu event is triggered when a user right-clicks an HTML element to display the context menu.

ondblclick event

The ondblclick event attribute is activated when an element is double-clicked. It allows you to run a specified script in response to the double-click action.

Syntax

In HTML

index.html
<element ondblclick="myScript">

In JS

script.js
object.ondblclick = function(){myScript};

In JavaScript, the addEventListener() function is used.

script.js
object.addEventListener("dblclick", myScript);

Example

::event-ondblclick ::
index.html
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The ondblclick Event</h2>
<p ondblclick="myFunction()">Double-click this paragraph to trigger a function.</p>
<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML += "Hello World ";
}
</script>

</body>
</html>

Values

Conclusion

The ondblclick event is triggered when an element is double-clicked, allowing scripts to respond to the action. It's useful for creating interactive elements that require a double-click for activation. This event enhances user engagement and interaction within a webpage.