jQuery dblclick() Method

Last Updated:

jQuery dblclick() Method

The jQuery dblclick() method is used for the following 2 purpose

  1. To run a callback when a specified element is double clicked.
  2. To trigger the dblclick event of a specified element.

Run a Callback

In the following example, we will run a callback function when a button is double clicked.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery dblclick() Method</h1> <p>Double click on the button to alert</p> <button>Double Click Me</button> <script> $(document).ready(function(){ $("button").dblclick(function(){ alert("Button doubled clicked"); }); }); </script> </body> </html>

Syntax

$(selector).dblclick(callback);

Parameter Values

ValueTypeExplanation
callback Optional Specifies a function to be called once the element is double clicked.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
dblclick()YesYesYesYesYesYesYesYesYesYesYesYesYes

Trigger a dblclick Event

In the following example, we will trigger a dblclick event when a paragraph is clicked.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery dblclick() Method</h1> <p>Click this paragraph to trigger dblclick event.</p> <button>Double Click Me</button> <script> $(document).ready(function(){ $("button").dblclick(function(){ alert("Button doubled clicked"); }); $("p").click(function(){ $("button").dblclick(); }); }); </script> </body> </html>

Share this Page

Meet the Author