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

回答編集履歴

3

コード修正

2021/04/12 03:05

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -64,12 +64,14 @@
64
64
 
65
65
  ---
66
66
  追記された仕様に対応するコードです。
67
- 上記のコードから不要なものを削除しただけです。
68
67
 
69
68
  ```js
70
69
  $("li input").on('click', function() {
70
+ if ($(this).prop('checked')== true){
71
- $(this).parents('ul').each(function(index) {
71
+ $(this).parents('ul').each(function(index) {
72
- $(this).prev().children().prop('checked', true);
72
+ $(this).prev().children().prop('checked', true);
73
- });
73
+ });
74
+ };
74
75
  });
75
- ```
76
+ ```
77
+ ※修正しました。4/12 12:05

2

コード追記

2021/04/12 03:05

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -59,4 +59,17 @@
59
59
  });
60
60
  });
61
61
  ```
62
- [CodePenサンプル](https://codepen.io/hatena19/pen/JjEMyYg)
62
+ [CodePenサンプル](https://codepen.io/hatena19/pen/JjEMyYg)
63
+
64
+
65
+ ---
66
+ 追記された仕様に対応するコードです。
67
+ 上記のコードから不要なものを削除しただけです。
68
+
69
+ ```js
70
+ $("li input").on('click', function() {
71
+ $(this).parents('ul').each(function(index) {
72
+ $(this).prev().children().prop('checked', true);
73
+ });
74
+ });
75
+ ```

1

リンク修正

2021/04/12 00:33

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -59,4 +59,4 @@
59
59
  });
60
60
  });
61
61
  ```
62
- [CodePenサンプル](https://codepen.io/hatena19/pen/JjEMyYg?editors=0011)
62
+ [CodePenサンプル](https://codepen.io/hatena19/pen/JjEMyYg)