<!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"?name="chTerm"?id="dd">
????????????<label>查看學(xué)期列表</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chTerm">
????????????<label>添加學(xué)期</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chTerm">
????????????<label>修改學(xué)期</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chTerm">
????????????<label>刪除學(xué)期</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chTerm">
????????????<label>停用/啟用學(xué)期</label>
????????</td>
????</tr>
????<tr>
????????<td?colspan="5">
????????????<span?class="font_bold?margin_X10">專業(yè)管理</span>
????????????<input?type="checkbox"?id="selectAllSpecialty">
????????????<label?for="selectAllSpecialty">全選</label>
????????</td>
????</tr>
????<tr?id="specialtyRow">
????????<td>
????????????<input?type="checkbox"?name="chAllSpecialty">
????????????<label>查看專業(yè)列表</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chAllSpecialty">
????????????<label>添加專業(yè)</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chAllSpecialty">
????????????<label>修改專業(yè)</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chAllSpecialty">
????????????<label>刪除專業(yè)</label>
????????</td>
????????<td>
????????????<input?type="checkbox"?name="chAllSpecialty">
????????????<label>停用/啟用專業(yè)</label>
????????</td>
????</tr>
</table>
<script>
?????var?checkList=$("input[name='chTerm']");
????function?selectAll?(id)?{
????????$(id).click(function?()?{
????????????checkList.prop("checked",?$(id).prop("checked"));
????????????hasAll();
????????});
????};
????function?hasAll(){
????????var?chknum?=?checkList.length;
????????var?Count=0;
????????for(var?i=0;i<chknum;i++){
????????????if(checkList[i].checked){
????????????????Count++;
????????????}
????????}
????????console.log(Count);
????????if(chknum==Count){//全選
????????????$("#selectAllTerm").prop("checked",true);
????????}else{//不全選
????????????$("#selectAllTerm").prop("checked",false);
????????}
????}
????selectAll(selectAllTerm);
????selectAll(selectAllSpecialty);
$(function(){
????$("input[name='chTerm']").each(function(){
????????$(this).click(function(){
????????????hasAll();
????????})
????})
})
</script>
</body>
</html>
以下js應(yīng)該怎樣封裝成fun(id,name){}
qq_sU_4
2016-07-21 14:59:03