Javatpoint Logo
Javatpoint Logo

JavaScript dblclick event

The dblclick event generates an event on double click the element. The event fires when an element is clicked twice in a very short span of time. We can also use the JavaScript's addEventListener() method to fire the double click event.

In HTML, we can use the ondblclick attribute to create a double click event.

Syntax

Now, we see the syntax of creating double click event in HTML and in javascript (without using addEventListener() method or by using the addEventListener() method).

In HTML

In JavaScript

In JavaScript by using the addEventListener() method

Let's see some of the illustrations to understand the double click event.

Example - Using ondblclick attribute in HTML

In this example, we are creating the double click event using the HTML ondblclick attribute.

Test it Now

Output

After the execution of the above code, the output will be -

JavaScript dblclick event

After double-clicking the text "Hello world", the output will be -

JavaScript dblclick event

Now, we will see how to create double click event using JavaScript.

Example - Using JavaScript

Test it Now

Output

JavaScript dblclick event

After double-clicking the text "Hello world", the output will be -

JavaScript dblclick event

Example - Using JavaScript's addEventListener() method

Test it Now

Output

JavaScript dblclick event

After double-clicking the text "Hello world", the output will be -

JavaScript dblclick event
Next TopicJavaScript onload





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA