-
Notifications
You must be signed in to change notification settings - Fork 0
/
muban.html
executable file
·84 lines (75 loc) · 2.06 KB
/
muban.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
.multiple input[type=checkbox] {
z-index: 20;
left: 0;
}
.multiple input[type=checkbox] + span {
display: inline-block;
vertical-align: middle;
width: 16px;
height: 16px;
border: solid 1px #898989;
background-color: #f8f8f8;
border-radius: 2px;
margin-right: 10px;
position: relative;
}
.multiple input[type=checkbox]:checked + span:before {
content: "";
position: absolute;
left: -2px; right: -2px;
top: -2px; bottom: -2px;
z-index: 3;
background: url(img/list/content/gou.png) no-repeat center center;
}
</style>
</head>
<body>
<label class="multiple">
<input type="checkbox" id="checkall"><span></span>
</label>
<form method="post" action="">
你爱好的运动是?<input type="checkbox" id="checkedAll_2" />全选/全不选
<br />
<label class="multiple">
<input type="checkbox" name="checkitem"><span></span>
</label>
<label class="multiple">
<input type="checkbox" name="checkitem"><span></span>
</label>
<label class="multiple">
<input type="checkbox" name="checkitem"><span></span>
</label>
</form>
<script type="text/javascript">
window.onload = function(){
document.getElementById("checkedAll_2").onclick = function(){
var flag = this.checked;
var items = document.getElementsByName("checkitem");
for(var i = 0; i < items.length; i++){
items[i].checked = flag;
}
};
var items = document.getElementsByName("items");
for(var i = 0; i < items.length; i++){
items[i].onclick = function(){
//记录有多少个 items 被选中了
var number = 0;
for(var j = 0; j < items.length; j++){
if(items[j].checked){
number++;
}
}
document.getElementById("checkedAll_2").checked =
(items.length == number);
}
}
}
</script>
</body>
</html>