回答編集履歴
1
sample
answer
CHANGED
@@ -1,3 +1,87 @@
|
|
1
1
|
getElementsByClassName()で得られるオブジェクトは複数なので
|
2
2
|
直接styleをいじることができません。
|
3
|
-
てっとりばやくはforなどで回してそれぞれ個別に処理してください
|
3
|
+
てっとりばやくはforなどで回してそれぞれ個別に処理してください
|
4
|
+
|
5
|
+
# sample
|
6
|
+
一応jQuery版をあげておきます
|
7
|
+
ラジオボタンの値をみて切り替えるようにしてあります。
|
8
|
+
テーブルは複数あってもかまいませんが、ラジオボタンの名前を共有すると
|
9
|
+
おかしくなるので少し変えてあります
|
10
|
+
|
11
|
+
```javascript
|
12
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
13
|
+
<script>
|
14
|
+
$(function(){
|
15
|
+
$('[type=radio]').on('change',function(){
|
16
|
+
$(this).parents('table').first().find('.firstBox').toggle($(this).val()=="0");
|
17
|
+
});
|
18
|
+
});
|
19
|
+
</script>
|
20
|
+
<form>
|
21
|
+
<table border="1" cellspacing="0" cellpadding="5">
|
22
|
+
<tr style="background:#EFEFEF;">
|
23
|
+
<th>
|
24
|
+
<label><input type="radio" name="entryPlan1" value="0" checked="checked" />初期はすべて表示</label>
|
25
|
+
<label><input type="radio" name="entryPlan1" value="1" />EEEE</label>
|
26
|
+
</th>
|
27
|
+
</tr>
|
28
|
+
<tr class="firstBox">
|
29
|
+
<th style="background:#FFCCCC;">Eを選んだ時 消える</th>
|
30
|
+
</tr>
|
31
|
+
<tr>
|
32
|
+
<td style="background:#FFCCCC;">
|
33
|
+
>Eを選んだ時 消える
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<tr class="secondBox">
|
37
|
+
<th style="background:#CCCCFF;">Eを選んだ時 表示のまま</th>
|
38
|
+
</tr>
|
39
|
+
<tr>
|
40
|
+
<td style="background:#CCCCFF;">
|
41
|
+
>Eを選んだ時 表示のまま
|
42
|
+
</td>
|
43
|
+
</tr>
|
44
|
+
<tr class="firstBox">
|
45
|
+
<th style="background:#FFCCCC;">Eを選んだ時 消える</th>
|
46
|
+
</tr>
|
47
|
+
<tr>
|
48
|
+
<td style="background:#FFCCCC;">
|
49
|
+
>Eを選んだ時 消える
|
50
|
+
</td>
|
51
|
+
</tr>
|
52
|
+
</table>
|
53
|
+
<table border="1" cellspacing="0" cellpadding="5">
|
54
|
+
<tr style="background:#EFEFEF;">
|
55
|
+
<th>
|
56
|
+
<label><input type="radio" name="entryPlan2" value="0" checked="checked" />初期はすべて表示</label>
|
57
|
+
<label><input type="radio" name="entryPlan2" value="1" />EEEE</label>
|
58
|
+
</th>
|
59
|
+
</tr>
|
60
|
+
<tr class="firstBox">
|
61
|
+
<th style="background:#FFCCCC;">Eを選んだ時 消える</th>
|
62
|
+
</tr>
|
63
|
+
<tr>
|
64
|
+
<td style="background:#FFCCCC;">
|
65
|
+
>Eを選んだ時 消える
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
<tr class="secondBox">
|
69
|
+
<th style="background:#CCCCFF;">Eを選んだ時 表示のまま</th>
|
70
|
+
</tr>
|
71
|
+
<tr>
|
72
|
+
<td style="background:#CCCCFF;">
|
73
|
+
>Eを選んだ時 表示のまま
|
74
|
+
</td>
|
75
|
+
</tr>
|
76
|
+
<tr class="firstBox">
|
77
|
+
<th style="background:#FFCCCC;">Eを選んだ時 消える</th>
|
78
|
+
</tr>
|
79
|
+
<tr>
|
80
|
+
<td style="background:#FFCCCC;">
|
81
|
+
>Eを選んだ時 消える
|
82
|
+
</td>
|
83
|
+
</tr>
|
84
|
+
</table>
|
85
|
+
</form>
|
86
|
+
```
|
87
|
+
|