abstract:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml&quo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.box{ width:120px; height:300px; border:1px solid;}
.box div{ border-bottom:1px solid; padding:10px }
.box input{ margin:10px}
</style>
<script type="text/javascript">
function checkall(){
var checkall=document.getElementById("checkall");
var item=document.getElementsByName("item[]");
for(var i = 0 ;i<item.length;i++){
if(checkall.checked){
item[i].checked = true
} else{
item[i].checked = false
}
}
}
</script>
</head>
<body>
<p>js学习</p>
<div class = "box">
<div>
<input type="checkbox" id = "checkall" onclick="checkall(this)"/>全选
</div>
<input type="checkbox" name= "item[]" />选项1<br />
<input type="checkbox" name= "item[]" />选项2<br />
<input type="checkbox" name= "item[]" />选项3<br />
<input type="checkbox" name= "item[]" />选项4<br />
<input type="checkbox" name= "item[]" />选项5<br />
<input type="checkbox" name= "item[]" />选项6<br />
<input type="checkbox" name= "item[]" />选项7<br />
</div>
</body>
</html>
Correcting teacher:查无此人Correction time:2019-04-18 09:56:26
Teacher's summary:完成的不错,js代码每行结束要增加;号。继续加油