测试结果:
点击全选时,选中所有选项:
html部分代码:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<script src="Test.js"></script>
<title>全选/复选框</title>
</head>
<input id="all" type="checkbox" value="false"/>全选</br>
<div id="checkbox">
<input id="c1" type="checkbox"/>篮球</br>
<input id="c2" type="checkbox"/>足球</br>
<input id="c3" type="checkbox"/>排球
<