Contents:
.on( "click" [, eventData ], handler )Returns: jQuery
Description: Bind an event handler to the "click" event.
-
version added: 1.7.on( "click" [, eventData ], handler )
click
event. For the deprecated .click()
method, see .click()
.
click
event is sent to an element when the mouse pointer is over the element, and the mouse button is pressed and released. Any HTML element can receive this event.
For example, consider the HTML:
1
2
3
4
5
6
|
|

<div>
:
1
2
3
|
|
1
2
3
|
|
click
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.
mousedown
or mouseup
event may be more suitable.
Examples:
Example 1
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
|
|
Demo:
Example 2
1
|
|
.trigger( "click" )Returns: jQuery
Description: Trigger the "click" event on an element.
-
version added: 1.0.trigger( "click" )
-
"click"Type: stringThe string
"click"
.
-
.on( "click", ... )
.