1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="../../../css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="../../../js/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="../../../js/bootstrap.min.js"></script>
<script language="javascript">
$().ready(function() {
    $("input[id=all]").click(function(){
        var allchecked = this.checked;
        var arr = $(this).parent().parent().parent().find("input");
        for(var i = 1;i<arr.length;i++){
            arr[i].checked = allchecked;
        }
    });
     
    $("input[id=inlineCheckbox1]").click(function(){
        var arr = $(this).parent().parent().parent().find("input");
        for(var i = 1;i<arr.length;i++){
            if(arr[i].checked){
                arr[0].checked = true;    
                return;
            }
        }
         
        var arr2 = $(this).parent().parent().parent().find("input[checked=true]");
        if(arr2.length ==0){
        arr[0].checked = false;    
        }
     
         
    })
     
     
});
</script>
</head>
<body>
  <table  class="table">
      <tr>
        <th>一级菜单</th>
        <th>二级菜单</th>
    </tr>
    <tr>
<td>
<label class="checkbox-inline">
  <input type="checkbox"  id="all" value="option1"> 系统管理
</label>
</td>
        <td>
        <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1"  value="option1"> 用户管理
        </label>
             <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>     <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>     <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>
        </td>
    </tr>   <tr>
<td>
<label class="checkbox-inline">
  <input type="checkbox" id="all" value="option1"> 系统管理
</label>
</td>
        <td>
        <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>
             <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>     <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>     <label class="checkbox-inline">
          <input type="checkbox" id="inlineCheckbox1" value="option1"> 用户管理
        </label>
        </td>
    </tr>
  </table>
</body>
</html>