回答編集履歴

3

ドロップ削除

2016/10/18 04:24

投稿

MaShiRo_H
MaShiRo_H

スコア328

test CHANGED
@@ -1,4 +1,4 @@
1
- ドラッグ&ドロップでの再現はできませんでしたが、あくまで憶測として、
1
+ ドラッグでの再現はできませんでしたが、あくまで憶測として、
2
2
 
3
3
  イベントをclickで発火させてるからじゃないかなあと。
4
4
 

2

blockの削除

2016/10/18 04:24

投稿

MaShiRo_H
MaShiRo_H

スコア328

test CHANGED
@@ -8,15 +8,15 @@
8
8
 
9
9
  ```HTML
10
10
 
11
- <input type="radio" id="radio1" name="radio_group" style="display:block">
11
+ <input type="radio" id="radio1" name="radio_group">
12
12
 
13
13
  <label for="radio1">テスト1</label>
14
14
 
15
- <input type="radio" id="radio2" name="radio_group" style="display:block">
15
+ <input type="radio" id="radio2" name="radio_group">
16
16
 
17
17
  <label for="radio2">テスト2</label>
18
18
 
19
- <input type="radio" id="radio3" name="radio_group" style="display:block">
19
+ <input type="radio" id="radio3" name="radio_group">
20
20
 
21
21
  <label for="radio3">テスト3</label>
22
22
 

1

詳細に

2016/10/18 03:35

投稿

MaShiRo_H
MaShiRo_H

スコア328

test CHANGED
@@ -6,17 +6,35 @@
6
6
 
7
7
 
8
8
 
9
+ ```HTML
10
+
11
+ <input type="radio" id="radio1" name="radio_group" style="display:block">
12
+
13
+ <label for="radio1">テスト1</label>
14
+
15
+ <input type="radio" id="radio2" name="radio_group" style="display:block">
16
+
17
+ <label for="radio2">テスト2</label>
18
+
19
+ <input type="radio" id="radio3" name="radio_group" style="display:block">
20
+
21
+ <label for="radio3">テスト3</label>
22
+
23
+ ```
24
+
25
+
26
+
9
27
  ```Javascript
10
28
 
11
29
  $(function(){
12
30
 
13
- $("input[type='radio']").on("change",function() {
31
+ var $radio = $("input[name='radio_group']")
14
32
 
15
- if ($(this).is(":checked")) {
33
+ $radio.on("change",function() {
16
34
 
17
- $(this).next("label").addClass("checked")
35
+ $radio.next("label").removeClass("checked")
18
36
 
19
- }
37
+ $(this).next("label").addClass("checked")
20
38
 
21
39
  })
22
40