用原生js跟jquery实现checkbox全选反选的一个例子
原生js:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>checkbox</title>
</head>
<body>
<div id="check-all">
<input type="checkbox" name="check-all">全选
</div>
<div id="sub-checkbox">
<input type="checkbox" name="sub-checkbox">
<input type="checkbox" name="sub-checkbox">
<input type="checkbox" name="sub-checkbox">
<input type="checkbox" name="sub-checkbox">
<input type="checkbox" name="sub-checkbox">
</div>
<script>
var checkAll = document.querySelector('[name=check-all]');
var subCheckbox = docum