
In case we want to execute a function on double click of the element, we can follow this approach.
Enter your name: <input type="text" name="txtName" id="txtName" /> <input type="button" id="btn" name="btn" value="Submit" ondblclick="CallFunction(this.id)" /> <script> function CallFunction(id) { alert("Double clicked"); } </script>
In the above code snippet, we have specified ondblclick
event in the button. When the button is double clicked, “CallFunction” function executes that shows an alert.
OUTPUT