-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13092401.html
More file actions
80 lines (66 loc) · 1.98 KB
/
13092401.html
File metadata and controls
80 lines (66 loc) · 1.98 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-latest.js"></script>
</head>
<body>
<input type="checkbox" id="ck1" name="color" value="black" onchange="b(this)"/> black
<input type="checkbox" id="ck2" name="color" value="red" onchange="b(this)"/> red
<input type="checkbox" id="ck3" name="color" value="white" onchange="b(this)"/> white
<input type="checkbox" id="ck4" name="color" value="green" onchange="b(this)"/> green
<input type="button" onclick="aaa()" value="submit"/>
<script>
function a() {
var count = 0;
for (var i = 0; i < 4; i++) {
var ss = "#ck";
ss = ss + ((i + 1) + '');
if ($(ss).prop("checked") == true) {
count++;
}
}
alert(count);
for (var i = 0; i < 4; i++) {
if ($(ss).prop("checked") == true) {
$(ss).prop("checked", false);
} else {
$(ss).prop("checked", true);
}
}
}
function b(thisone) {
// if (thisone.checked == true) {
// console.info(thisone.value);
// }
if ($(thisone).prop("checked") == true) {
console.info($(thisone).prop("value"));
}
}
function aa() {
console.info($(":checkbox").length);
console.info($(":checkbox")[1].value);
console.info($(":checkbox").get(1).value);
console.info($(":checkbox").eq(1).prop("value"));
}
function aaa() {
var count = 0;
//count selected checkboxes
$(":checkbox").each(function () {
if (this.checked == true) {
count++;
}
})
alert(count);
//first checkbox is true
if ($(":checkbox")[0].checked == true) {
$(":checkbox").each(function (ind, ele) {
if (ind % 2 == 0) {
ele.checked = true;
}
})
}
}
</script>
</body>
</html>