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

 Views: 5433 | Post Order: 40



Write for us






Hosting Recommendations