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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
window.onload=function(){
document.getElementById('allche').addEventListener('click', function(){
let ck = document.getElementsByName('ck1');
if(this.checked==true){
console.log('t1');
for(let i=0;i<ck.length;i++){
ck[i].checked=true;
}
}else{
console.log('t2');
}
}
)};
</script>
</head>
<body>
<form>
<label for="allche">전체체크</label>
<input type="checkbox" id="allche" name="allche" value="allche"><br>
<br><br>
<label for="jch">java</label>
<input type="checkbox" name="ck1"><br>
<label for="jspch">jsp</label>
<input type="checkbox" name="ck1" id="jsp"><br>
<label for="jch">php</label>
<input type="checkbox" name="ck1" id="php"><br>
<label for="jch">asp</label>
<input type="checkbox" name="ck1" id="asp"><br>
</form>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
반응형
'2019 > JavaScript' 카테고리의 다른 글
JS children & childnode (0) | 2019.12.09 |
---|---|
JS elementSibling (0) | 2019.12.09 |
JS onchange (0) | 2019.12.09 |
JS addEventListener 연습 (0) | 2019.12.09 |
JS create Element (0) | 2019.12.09 |