質問するログイン新規登録

回答編集履歴

1

調整

2018/11/27 06:33

投稿

yambejp
yambejp

スコア118024

answer CHANGED
@@ -4,4 +4,49 @@
4
4
  $('input[name=chk1]').prop('checked', $(this).prop('checked'));
5
5
  });
6
6
  });
7
+ ```
8
+ # 追記
9
+
10
+ ```javascript
11
+ <script>
12
+ $(function(){
13
+ $('#checkAll').on('click', function() {
14
+ $('input[name=chk1]').prop('checked', $(this).prop('checked')).trigger('change');
15
+ });
16
+ $('input[name=chk1]').on('change',function(){
17
+ console.log($(this).val());
18
+ })
19
+ });
20
+ </script>
21
+
22
+ <table>
23
+ <tbody>
24
+ <tr class="">
25
+ <th><input type="checkbox" id ="checkAll"/></th>
26
+ <th>社員番号</th>
27
+ <th>社員名</th>
28
+ </tr>
29
+ <tr class="list">
30
+ <td class="checkboxParent">
31
+ <input class="Select" type="checkbox" name="chk1" value="1">
32
+ </td>
33
+ <td class="Data">1</td>
34
+ <td class="Data">社員A</td>
35
+ </tr>
36
+ <tr class="list">
37
+ <td class="checkboxParent">
38
+ <input class="Select" type="checkbox" name="chk1" value="2">
39
+ </td>
40
+ <td class="Data">2</td>
41
+ <td class="Data">社員B</td>
42
+ </tr>
43
+ <tr class="list">
44
+ <td class="checkboxParent">
45
+ <input class="Select" type="checkbox" name="chk1" value="3">
46
+ </td>
47
+ <td class="Data">3</td>
48
+ <td class="Data">社員C</td>
49
+ </tr>
50
+ </tbody>
51
+ </table>
7
52
  ```