回答編集履歴

2

chousei

2021/09/21 10:35

投稿

yambejp
yambejp

スコア116738

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  $('#chk').on('click',function(){
10
10
 
11
- let forcusNum = $('input:radio[name="Genre"]').index($(':checked'));
11
+ var forcusNum = $('[name=Genre]').index($(':checked'));
12
12
 
13
13
  console.log(forcusNum);
14
14
 

1

chousei

2021/09/21 10:35

投稿

yambejp
yambejp

スコア116738

test CHANGED
@@ -2,8 +2,40 @@
2
2
 
3
3
  ```javascript
4
4
 
5
- let forcusNum = $('input:radio[name="Genre"]').index($(':checked'));
5
+ <script>
6
6
 
7
+ $(function(){
8
+
9
+ $('#chk').on('click',function(){
10
+
11
+ let forcusNum = $('input:radio[name="Genre"]').index($(':checked'));
12
+
7
- console.log(forcusNum);
13
+ console.log(forcusNum);
14
+
15
+ });
16
+
17
+ });
18
+
19
+ </script>
20
+
21
+ <form>
22
+
23
+ <label><input name="Genre" type="radio" value="aaa">A</label>
24
+
25
+ <label><input name="Genre" type="radio" value="bbb">B</label>
26
+
27
+ <label><input name="Genre" type="radio" value="ccc">C</label>
28
+
29
+ <label><input name="Genre" type="radio" value="ddd">D</label>
30
+
31
+ <label><input name="Genre" type="radio" value="eee">E</label><br>
32
+
33
+ <input type="button" id="chk" value="check">
34
+
35
+ <input type="reset" value="resett">
36
+
37
+ </form>
38
+
39
+
8
40
 
9
41
  ```