Horje
HTML ondblclick Attribute

Definition and Usage

The ondblclick attribute fires on a mouse double-click on the element.


Applies to

The ondblclick attribute is part of the Event Attributes, and can be used on any HTML elements.

Elements Event
All HTML elements ondblclick


How to Execute a JavaScript when a button is double-clicked

Button Example.
index.html
Example: TRY
<!DOCTYPE html>
<html>
<body>

<button ondblclick="myFunction()">Double-click me</button>

<p id="demo"></p>

<p>A function is triggered when the button is double-clicked. The function outputs some text in a p element with id="demo".</p>

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

</body>
</html>

Output should be:

How to Execute a JavaScript when a button is double-clicked

How to Double-click on a <p> element to change its text color to red

P Example.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p id="demo" ondblclick="myFunction()">Double-click me to change my text color.</p>

<p>A function is triggered when the p element is double-clicked. The function sets the color of the p element to red.</p>

<script>
function myFunction() {
  document.getElementById("demo").style.color = "red";
}
</script>

</body>
</html>

Output should be:

How to Double-click on a <p> element to change its text color to red




html ondblclick attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference