Double-click on a <p> element to alert a text:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from w ww . ja v a 2s. com*/ <script> $(document).ready(function(){ $("p").dblclick(function(){ document.getElementById("demo").innerHTML = "The paragraph was double-clicked."; }); }); </script> </head> <body> <p id="demo"></p> <p>Double-click on this paragraph.</p> </body> </html>
The dblclick event occurs when an element is double-clicked.
The dblclick()
method triggers the dblclick event.
The dblclick()
method can also run a function when a dblclick event occurs.
The dblclick event also generates a click event.
To trigger the dblclick event for the selected elements:
$(selector).dblclick()
Attach a function to the dblclick event:
$(selector).dblclick(function)
Parameter | Optional | Description |
---|---|---|
function | Optional. | Specifies the function to run when the dblclick event occurs |