JavaScript ondblclick Event Example

Updated on     Kisan Patel

If we want to execute a javascript function when user double click of an element, we need to use javascript ondblclick event.

<!-- HTML -->
<input type="button" id="btn" name="btn" value="Double click on me" ondblclick="TestFunction("/>

<!-- Javascript -->
<script type="text/javascript">
function TestFunction(id) {
   alert("You have Double clicked me!");

In the above code snippet, we have specified ondblclick event in the button. When the button is double clicked, TestFunction function executes that shows an alert.

See the Pen GJLpmb by Kisan (@pka246) on CodePen.


Leave a Reply