摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>全选</title> <style type="text/css"> .box{width: 88px;margin
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>全选</title>
<style type="text/css">
.box{width: 88px;margin: 60px auto;border:1px solid #ccc;border-radius: 8px;padding: 8px;font-size: 12px;}
.box_1{border-bottom: 1px solid #666;padding-bottom: 6px;}
input{margin-left: 12px;margin-top: 6px;}
</style>
<script type="text/javascript">
function checkall(){
var checkall,item;
checkall=document.getElementById("checkall")
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>
<div>
<div>
<input type="checkbox" id="checkall" onclick="checkall()"><label for="checkall">全选</label>
</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>
</div>
</body>
</html>
批改老师:天蓬老师批改时间:2019-01-24 17:25:12
老师总结:将这些<input>放到<form>标签中, 就可以以对象的方式对input中的内容进行操作了, 更加的方便