質問編集履歴

1

ご指摘いただいたようにコードを修正いたしました。

2020/12/22 07:21

投稿

20200713
20200713

スコア16

test CHANGED
File without changes
test CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
 
17
17
  ```html
18
+
19
+ 修正前
18
20
 
19
21
  <form name="form1">
20
22
 
@@ -50,9 +52,49 @@
50
52
 
51
53
  </form>
52
54
 
55
+
56
+
57
+ 修正後
58
+
59
+ <form name="form1">
60
+
61
+ <input checked type="checkbox" id="check1" onClick="displayTR_checkbox('check1','tr1');"><label for="check1">tr1</label><br>
62
+
63
+ <input checked type="checkbox" id="check2" onClick="displayTR_checkbox('check2','tr2');"><label for="check2">tr2</label>
64
+
65
+
66
+
67
+ <table class="picTable">
68
+
69
+ <tr id="tr1">
70
+
71
+ <td><img src="http://placehold.jp/150x150.png"></td>
72
+
73
+ <td><img src="http://placehold.jp/150x150.png"></td>
74
+
75
+ <td><img src="http://placehold.jp/150x150.png"></td>
76
+
77
+ </tr>
78
+
79
+ <tr id="tr2">
80
+
81
+ <td><img src="http://placehold.jp/150x150.png"></td>
82
+
83
+ <td><img src="http://placehold.jp/150x150.png"></td>
84
+
85
+ <td><img src="http://placehold.jp/150x150.png"></td>
86
+
87
+ </tr>
88
+
89
+ </table>
90
+
91
+ </form>
92
+
53
93
  ```
54
94
 
55
95
  ```javascript
96
+
97
+ 修正前
56
98
 
57
99
  function displayTR_checkbox(this,trID){
58
100
 
@@ -65,6 +107,26 @@
65
107
  } else {
66
108
 
67
109
  TR.style.display = block;
110
+
111
+ }
112
+
113
+ }
114
+
115
+ 修正後
116
+
117
+ function displayTR_checkbox(checkboxID,trID){
118
+
119
+ var TR = document.getElementById(trID);
120
+
121
+ var Checkbox = document.getElementById(checkboxID);
122
+
123
+ if(! Checkbox.checked){
124
+
125
+ TR.style.display = '';
126
+
127
+ } else {
128
+
129
+ TR.style.display = 'none';
68
130
 
69
131
  }
70
132