Contents:
.on( "dblclick" [, eventData ], handler )Returns: jQuery
Description: Bind an event handler to the "dblclick" event.
-
version added: 1.7.on( "dblclick" [, eventData ], handler )
This page describes the dblclick
event. For the deprecated .dblclick()
method, see .dblclick()
.
The dblclick
event is sent to an element when the element is double-clicked. Any HTML element can receive this event.
For example, consider the HTML:
1
2
3
4
5
6
|
|
The event handler can be bound to any <div>
:
1
2
3
|
|
Now double-clicking on this element displays the alert:
Handler for `dblclick` called.
To trigger the event manually, call .trigger( "dblclick" )
:
1
2
3
|
|
After this code executes, (single) clicks on Trigger the handler will also alert the message.
The dblclick
event is only triggered after this exact series of events:
- The mouse button is depressed while the pointer is inside the element.
- The mouse button is released while the pointer is inside the element.
- The mouse button is depressed again while the pointer is inside the element, within a time window that is system-dependent.
- The mouse button is released while the pointer is inside the element.
It is inadvisable to bind handlers to both the click
and dblclick
events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click
events before the dblclick
and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.
Examples:
To bind a "Hello World!" alert box to the dblclick event on every paragraph on the page:
1
2
3
|
|
Double click to toggle background color.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
|
Demo:
.trigger( "dblclick" )Returns: jQuery
Description: Trigger the "dblclick" event on an element.
-
version added: 1.0.trigger( "dblclick" )
-
"dblclick"Type: stringThe string
"dblclick"
.
-
See the description for .on( "dblclick", ... )
.