<script src="js/plugin/jquery-1.9.0.js"></script>
$(document).ready(function() { $("#selectAll").click(function() { $("input[name='subBox']").each(function() { this.checked = true; }); }); $("#reverse").click(function() { $("input[name='subBox']").each(function() { if (this.checked) { this.checked = false; } else { this.checked = true; } }); }); $("#checkItems").click(function() { $("input[name='subBox']").each(function() { if (this.checked) { this.checked = false; } else { this.checked = true; } }); }); });
<td width="15px" align="left"><input type="checkbox" id="checkItems"/></td> <td width="35px"><a id="selectAll" name="selectAll" style="cursor: pointer;">全选</a></td> <td width="35px"><a id="reverse" name="reverse" style="cursor: pointer;">反选</a></td>
<td class="check first_child"> <input type="checkbox" name="subBox" value=""/></span> </td>