复选框一键全选(练习)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="checkbox"><br><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>

<script>
var a=document.getElementsByTagName("input")

a[0].onclick=function(){
for(var i=1;i<a.length;i++){
a[i].checked=this.checked;
}

}
</script>
</body>
</html>

posted @ 2017-04-19 23:13  非凡。  阅读(433)  评论(0编辑  收藏  举报