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

回答編集履歴

4

ラジオボタンの処理がバグっているため修正

2020/08/24 02:04

投稿

root_jp
root_jp

スコア4666

answer CHANGED
@@ -1,8 +1,10 @@
1
1
  ```JavaScript
2
2
  $(function () {
3
- // ラジオボタンがクリックされたら
3
+ // // ラジオボタンがクリックされたら
4
4
  $("input[name='cr2']").on("click", function() {
5
+ $("input[name='cr2']").each(function() {
5
- $(this).closest(".c-table__tr").toggleClass("active");
6
+ $(this).closest(".c-table__tr").toggleClass("active", this.checked);
7
+ })
6
8
  });
7
9
 
8
10
  // 「全選択」する

3

元ソースに似たようなコメントも追記

2020/08/24 02:04

投稿

root_jp
root_jp

スコア4666

answer CHANGED
@@ -1,5 +1,6 @@
1
1
  ```JavaScript
2
2
  $(function () {
3
+ // ラジオボタンがクリックされたら、
3
4
  $("input[name='cr2']").on("click", function() {
4
5
  $(this).closest(".c-table__tr").toggleClass("active");
5
6
  });

2

ラジオボタンの処理が抜けていたので追記

2020/08/24 01:56

投稿

root_jp
root_jp

スコア4666

answer CHANGED
File without changes

1

ラジオボタンの処理が抜けていたので追記

2020/08/24 01:55

投稿

root_jp
root_jp

スコア4666

answer CHANGED
@@ -1,5 +1,9 @@
1
1
  ```JavaScript
2
2
  $(function () {
3
+ $("input[name='cr2']").on("click", function() {
4
+ $(this).closest(".c-table__tr").toggleClass("active");
5
+ });
6
+
3
7
  // 「全選択」する
4
8
  $("#all").on("click", function () {
5
9
  $("input[name='chk[]']").prop("checked", this.checked).closest(".c-table__tr").toggleClass("active", this.checked);
@@ -13,5 +17,4 @@
13
17
  $(this).closest(".c-table__tr").toggleClass("active");
14
18
  });
15
19
  });
16
-
17
20
  ```