JavaScript > Events

Ondblclick in JavaScript

How to execute a function when an element is double clicked in JavaScript?

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(" />

        function CallFunction(id) {
            alert("Double clicked");

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.


 Views: 1245 | Post Order: 40

Write for us