-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08.html
58 lines (55 loc) · 1.26 KB
/
08.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.title{
text-align: center;
line-height: 50px;
width: 300px;
height: 50px;
border:3px solid #fff;
background-color: rgba(0,0,0,0.4);
color: #FFFFFF;
margin: 0 auto;
}
.k{
width: 1200px;
margin: 100px auto;
}
input[type="button"]{
margin: 10px;
width: 200px;
height: 100px;
background:rgba(0,0,0,0.4);
color: #fff;
font-size: 2em;
cursor: pointer;
}
input[type="button"]:hover{
background-color: blue;
color: red;
}
</style>
</head>
<body>
<div class="k">
<input type="button" value="A" />
<input type="button" value="B" />
<input type="button" value="C" />
<input type="button" value="D" />
</div>
<script type="text/javascript">
var oBtnList=document.querySelectorAll(".k input");
for ( var i = 0; i < oBtnList.length; i++ ) {
oBtnList[ i ].addEventListener("click",(function(index){
return function(e){
console.log( '你单击了第' + index +"个按钮" )
alert('你单击了第' + index +"个按钮");
};
}(i+1)));
}
</script>
</body>
</html>