<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table border="1px" id="tb">
<tr>
<td>
<input type="checkbox" onClick="fun()" id="tb1">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="cb1" >
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="cb1">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="cb1">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="cb1">
</td>
</tr>
</table>
<script>
function fun(){
var a = document.getElementById("tb1")
var b = a.checked;
//获取的状态(是否选择)
var c = document.getElementsByName("cb1");
for(var i=0;i<c.length;i++){
var d = c[i];
d.checked = b;
}
}
</script>
</body>
</html>
</body>
</html>
9.3全选和全不选(改)
最新推荐文章于 2020-04-24 14:22:26 发布