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(this.id)"/> <!-- Javascript --> <script type="text/javascript"> function TestFunction(id) { alert("You have Double clicked me!"); } </script>
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.