forked from AttackXiaoJinJin/jQueryExplain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQuery之事件委托的currenttarget研究.html
89 lines (69 loc) · 1.99 KB
/
jQuery之事件委托的currenttarget研究.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery之事件委托的currenttarget研究</title>
</head>
<body>
<script src="jQuery.js"></script>
<!--<script src="jQuery3.4.1.js"></script>-->
<div id="A" style="background-color: deeppink" tabindex="0">
这是A
<!--<div id="B" style="background-color: bisque" >-->
<!--这是B-->
<div id="C" style="background-color: aqua" tabindex="1">
这是C
</div>
<!--<div id="D" style="background-color: blueviolet">-->
<!--这是D-->
<!--</div>-->
<!--</div>-->
</div>
<!--<div id="E" style="background-color: brown">这是E</div>-->
<script>
// $("#A").on("click" ,"#B",function () {
// console.log("A委托B被点击了")
// })
$("#A").on("click" ,function (event) {
console.log(event,"A被点击了")
})
// $("#A").on("click" ,function (event) {
// console.log(event,"A又被点击了")
// })
$("#A").trigger("click")
// $("#A").on("focus" ,function (event) {
// console.log(event,"A被focus了")
// })
// $("#A").on("click" ,"#E",function (event) {
// $("#A").on("click" ,"#C",function (event) {
// // event.stopPropagation()
// // console.log(event,"点击了E,即E委托A的click事件被点击了")
// console.log(event,"点击了C,即C委托A的click事件被点击了")
// })
// console.log($("#B").find('#C'),'find46');
// console.log($("#A"),'aaaaaa46')
// $("#C").on("click",function (event) {
// $("#C").on("focus",function (event) {
// console.log(event,"C被点击了")
// console.log(event,"C被focus了")
// })
// $("#A").on("click" ,function (e) {
// console.log(e,"A被点击了")
// })
//
//
// $("#C").on("click" ,function (e) {
// e.stopPropagation()
// console.log(e,"C被点击了")
// })
//
// $("#B").on("click" ,function () {
// console.log("B被点击了")
// })
//
// $("#C").on("click",function () {
// console.log("C被点击了")
// })
</script>
</body>
</html>