forked from AttackXiaoJinJin/jQueryExplain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQuery之click().html
71 lines (53 loc) · 1.44 KB
/
jQuery之click().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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery源码解析之addClass()</title>
</head>
<body>
<script src="jQuery.js"></script>
<!--<a id="one" href="https://www.baidu.com">这是one</a>-->
<a id="one" style="border:1px blue solid">这是one
<div id="three" style="border:1px red solid">这是three</div>
</a>
<script>
// $("#one").click()
// $("body").click(function(){
// console.log('body被点击了')
// })
// let one=document.getElementById("one")
// let three=document.getElementById("three")
// one.onclick=function(){
// console.log('onclick被点击了')
// }
//在父元素上绑定click事件,但只能由子元素触发,父元素不触发
// $("#one").on("click",'#three' ,function () {
// console.log("one被点击了")
// })
// $("#one").on("click",function () {
// console.log("two被点击了")
// })
$("#one").on("click",'#three',function () {
console.log("one被点击了")
})
// $("#one").on("focus",function () {
// console.log("two被点击了")
// })
// $("#one").off("click.one")
// $("#one").trigger('click')
// $("#one").trigger('click')
//
// $("#one").trigger('click')
// $("#one").trigger('click')
// console.log($("#one").trigger('click'),'click30')
// let a=function () {
// console.log('aaaa')
// return null
// //return undefiend
// }
//
// let b=22||a()
// console.log(b,'bbb51')
</script>
</body>
</html>