abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>全選</title><style type="text/css">.box{width:120px;border:1px solid #000;border-rad
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>全選</title>
<style type="text/css">
.box{width:120px;border:1px solid #000;border-radius:5px;padding:5px 10px;margin: 20px auto;}
.box div{border-bottom: 1px solid pink;padding-bottom: 10px;margin-bottom: 8px;}
.box input{margin: 8px}
</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[]">選項(xiàng)1<br>
<input type="checkbox" name="item[]">選項(xiàng)2<br>
<input type="checkbox" name="item[]">選項(xiàng)3<br>
<input type="checkbox" name="item[]">選項(xiàng)4<br>
</div>
</body>
</html>
//總結(jié):授課細(xì)節(jié)及邏輯需要改進(jìn),可能我比較追求完美
Correcting teacher:滅絕師太Correction time:2019-01-08 09:19:11
Teacher's summary:收到你的反饋啦!全選完成的不錯(cuò),后期運(yùn)用的比較多,所以一定要好好掌握!