How to handle a double click event using jQuery?

To handle a double click event using jQuery, use the dblclick() event. When an element is double clicked, this event occurs. The dblclick() method triggers the double-click event or attaches a function to run when a double-click event occurs on the selected elements.

Syntax

The basic syntax for the dblclick() method is ?

$(selector).dblclick(function)

Where function is optional and specifies the function to run when the double-click event occurs.

Example

You can try to run the following code to learn how to handle double click event using jQuery ?

<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("p").dblclick(function(){
                alert("You have double-clicked this paragraph!");
            });
        });
    </script>
</head>
<body>
    <p style="background-color: lightblue; padding: 20px; cursor: pointer;">Double click this paragraph</p>
</body>
</html>

In this example, when you double-click on the paragraph element, an alert box will appear with the message "You have double-clicked this paragraph!".

Conclusion

The jQuery dblclick() method provides a simple way to handle double-click events on HTML elements. It's commonly used for interactive features like expanding content, editing text, or triggering special actions that require intentional user interaction.

Updated on: 2026-03-13T19:01:19+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements