<!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>
求大神幫忙
qq_sU_4
2016-07-20 17:42:23