<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery.min.js"></script>
</head>
<body>
<table id="setPermission" class="table marginTop_30">
<tr>
<td colspan="5">
<span class="font_bold margin_X10">角色管理</span>
<input type="checkbox" id="selectAllTerm">
<label for="selectAllTerm">全选</label>
</td>
</tr>
<tr id="termRow">
<td>
<input type="checkbox">
<label>查看学期列表</label>
</td>
<td>
<input type="checkbox">
<label>添加学期</label>
</td>
<td>
<input type="checkbox">
<label>修改学期</label>
</td>
<td>
<input type="checkbox">
<label>删除学期</label>
</td>
<td>
<input type="checkbox">
<label>停用/启用学期</label>
</td>
</tr>
<tr>
<td colspan="5">
<span class="font_bold margin_X10">专业管理</span>
<input type="checkbox" id="selectAllSpecialty">
<label for="selectAllSpecialty">全选</label>
</td>
</tr>
<tr id="specialtyRow">
<td>
<input type="checkbox">
<label>查看专业列表</label>
</td>
<td>
<input type="checkbox">
<label>添加专业</label>
</td>
<td>
<input type="checkbox">
<label>修改专业</label>
</td>
<td>
<input type="checkbox">
<label>删除专业</label>
</td>
<td>
<input type="checkbox">
<label>停用/启用专业</label>
</td>
</tr>
</table>
<!--如果子选项取消勾选一个,全选按钮就取消勾选;反之全选了子选项,全选按钮默认勾选。这个功能赢该怎么写??-->
<script>
selectAll = function (obj) {
var checklist = $(obj).parent().parent().next().find("input[type='checkbox']");
$(obj).click(function () {
$(obj).parent().parent().next().find("input[type='checkbox']").prop("checked", $(obj).prop("checked"));
});
}
selectAll($("#selectAllTerm"));
selectAll($("#selectAllSpecialty"));
</script>
</body>
</html>