-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path47(事件绑定(通过html标签绑定事件)).html
51 lines (50 loc) · 1 KB
/
47(事件绑定(通过html标签绑定事件)).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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body{
background-color: wheat;
}
#kuai,#kuai1,#kuai2,#kuai3{
margin: auto;
width: 500px;
height: 100px;
}
#kuai{
background: red;
}
#kuai1{
background: yellowgreen;
}
#kuai2{
background:blueviolet;
}
#kuai3{
background: pink;
}
</style>
<script type="text/javascript">
function one(){
document.body.style.backgroundColor ="red";
}
function two(){
document.body.style.backgroundColor ="green";
}
function three(){
document.body.style.backgroundColor ="darkblue";
}
function four(){
document.body.style.backgroundColor ="pink";
}
</script>
</head>
<body>
<!--通过标签绑定事件,这里的函数要加()-->
<div id="kuai" onclick="one()"></div>
<div id="kuai1" onclick="two()"></div>
<div id="kuai2" onclick="three()"></div>
<div id="kuai3" onclick="four()"></div>
</body>
</html>