-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.html
More file actions
63 lines (48 loc) · 1.94 KB
/
4.html
File metadata and controls
63 lines (48 loc) · 1.94 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script>
function countChecked() {
// alert($("input[type='radio']:checked").attr("value"));
if ($("input[type='radio']:checked").attr("value") == "color1") {
alert($("input[name='color1']:checked").length);
$("input[name='color1']:checked").each(function () {
if ($(this).prop("checked") == true) {
$(this).prop("checked",false);
} else {
alert($(this).prop("checked"));
$(this).attr("checked","checked");
}
})
} else if ($("input[type='radio']:checked").attr("value") == "color2") {
alert($("input[name='color2']:checked").length);
$("input[name='color2']:checked").each(function () {
if ($(this).prop("checked") == true) {
$(this).prop("checked", false);
} else {
$(this).prop("checked", true);
}
})
}
}
</script>
</head>
<body>
<input type="checkbox" name="color1" value="黑"/>黑
<input type="checkbox" name="color1" value="红"/>红
<input type="checkbox" name="color1" value="白"/>白
<input type="checkbox" name="color1" value="黄"/>黄
<br>
<input type="checkbox" name="color2" value="绿"/>绿
<input type="checkbox" name="color2" value="蓝"/>蓝
<input type="checkbox" name="color2" value="橙"/>橙
<input type="checkbox" name="color2" value="紫"/>紫
<br>
<input type="radio" name="rSelect" value="color1"/>第一组
<input type="radio" name="rSelect" value="color2"/>第二组
<input type="button" value="输出" onclick="countChecked()"/>
</body>
</html>