效果:
<!doctype html>
<html lang="en"><head>
<meta charset="UTF-8">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>一键反选</title>
<style>
*{margin:0px;padding:0px;}
form table{
width:500px;
margin:10px auto;
border-right:1px solid red;
border-bottom:1px solid red;
border-collapse:collapse;
}
tr td{
border-left:1px solid red;
border-top:1px solid red;
}
</style>
<script>
window.οnlοad=function(){
var arrs = document.getElementsByClassName("checkbox");
if(arrs.length >0 ){
arrs[0].οnclick=function(){
for(var i = 1; i < arrs.length; i++){
arrs[i].checked = !arrs[i].checked;
}
}
}
}
</script>
</head>
<body>
<form action="" method="post">
<table>
<tr>
<td width="20px"><input type="checkbox" class="checkbox"></td>
<td>123</td>
</tr>
<tr>
<td><input type="checkbox" class="checkbox"></td>
<td>123</td>
</tr>
<tr>
<td><input type="checkbox" class="checkbox"></td>
<td>123</td>
</tr>
</table>
</form>
</body>
</html>