Display a paragraph's text in an alert when it is clicked:
1
2
3
|
|
Pass data to the event handler, which is specified here by name:
1
2
3
4
|
|
Cancel a form submit action and prevent the event from bubbling up by returning false
:
1
|
|
Cancel only the default action by using .preventDefault()
.
1
2
3
|
|
Stop submit events from bubbling without preventing form submit, using .stopPropagation()
.
1
2
3
|
|
Pass data to the event handler using the second argument to .trigger()
1
2
3
4
|
|
Use the the second argument of .trigger()
to pass an array of data to the event handler
1
2
3
4
|
|
Attach and trigger custom (non-browser) events.
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
34
35
36
37
38
|
|
Демонстрация:
Attach multiple event handlers simultaneously using a plain object.
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
34
35
36
37
38
|
|
Демонстрация:
Click any paragraph to add another after it. Note that .on()
allows a click event on any paragraph--even new ones--since the event is handled by the ever-present body element after it bubbles to there.
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
34
35
|
|
Демонстрация:
Display each paragraph's text in an alert box whenever it is clicked:
1
2
3
|
|
Cancel a link's default action using the .preventDefault()
method:
1
2
3
|
|
Attach multiple events—one on mouseenter
and one on mouseleave
to the same element:
1
2
3
|
|