好像有点错误点,我懒的找错误点,就这样把,将就看,也没有解说!我就单纯想打着玩。授权即删
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>p177作业</title>
</head>
<body>
<table>
<tr>
<th>操作</th>
<th>编号</th>
<th>图书名称</th>
<th>价格</th>
</tr>
<tr>
<td><input class = 'check' type="checkbox" ></td>
<td>1</td>
<td>测试1</td>
<td>40</td>
</tr>
<tr>
<td><input class = 'check' type="checkbox"></td>
<td>2</td>
<td>测试2</td>
<td>80</td>
</tr>
<tr>
<td><input class = 'check' type="checkbox"></td>
<td>3</td>
<td>测试3</td>
<td>30</td>
</tr>
<input id="select all" type="button" value="全选">
<input id="not at all" type="button" value="全不选">
<input id="anti election" type="button" value="反选">
<script>
var select all = document.getElementById('checkAll');//全选
var not at all = document.getElementById('checkNone');//全不选
var anti election = document.getElementById('chackInvert');//反选
var checkList = document.getElementsByClassName('check');//选择框列表
checkAll.onclick = function(){
for(var i = 0;i<checkList.length;i++){
checkList[i].checked = true;
}
}
unCheckAll.onclick = function(){
for(var i = 0;i<checkList.length;i++){
checkList[i].checked = false;
}
}
reverseCheck.onclick = function(){
for(var i = 0;i<checkList.length;i++){
checkList[i].checked = !checkList[i].checked;
}
}
</script>
</body>
</html>