回答編集履歴
1
追記
test
CHANGED
@@ -193,3 +193,205 @@
|
|
193
193
|
</html>
|
194
194
|
|
195
195
|
```
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
追記
|
200
|
+
|
201
|
+
---
|
202
|
+
|
203
|
+
上記のコードのうち2箇所を修正しました。
|
204
|
+
|
205
|
+
```HTML
|
206
|
+
|
207
|
+
<!DOCTYPE html>
|
208
|
+
|
209
|
+
<html lang="ja">
|
210
|
+
|
211
|
+
<head>
|
212
|
+
|
213
|
+
<meta charset="UTF-8">
|
214
|
+
|
215
|
+
<title>タイトル</title>
|
216
|
+
|
217
|
+
<style type="text/css">
|
218
|
+
|
219
|
+
.test th {
|
220
|
+
|
221
|
+
border: 1px solid #FFF;
|
222
|
+
|
223
|
+
padding: 7px;
|
224
|
+
|
225
|
+
background: #000;
|
226
|
+
|
227
|
+
color: #FFF;
|
228
|
+
|
229
|
+
text-align: center;
|
230
|
+
|
231
|
+
vertical-align: middle;
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
.test {
|
238
|
+
|
239
|
+
width: 100%;
|
240
|
+
|
241
|
+
border-collapse: collapse;
|
242
|
+
|
243
|
+
padding: 0;
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
.test td {
|
250
|
+
|
251
|
+
border: 1px solid black;
|
252
|
+
|
253
|
+
padding: 10px;
|
254
|
+
|
255
|
+
vertical-align: middle;
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
.test td {
|
262
|
+
|
263
|
+
border-top: none !important;
|
264
|
+
|
265
|
+
border-right: 1px solid #000;
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
.waku {
|
272
|
+
|
273
|
+
position: relative;
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
.waku a::after {
|
280
|
+
|
281
|
+
position: absolute;
|
282
|
+
|
283
|
+
width: 100%;
|
284
|
+
|
285
|
+
height: 100%;
|
286
|
+
|
287
|
+
content: "";
|
288
|
+
|
289
|
+
top: 0;
|
290
|
+
|
291
|
+
left: 0;
|
292
|
+
|
293
|
+
right: 0;
|
294
|
+
|
295
|
+
bottom: 0;
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
.th1 {
|
302
|
+
|
303
|
+
padding: 10px;
|
304
|
+
|
305
|
+
display: table-cell;
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
</style>
|
310
|
+
|
311
|
+
</head>
|
312
|
+
|
313
|
+
<body>
|
314
|
+
|
315
|
+
<label>
|
316
|
+
|
317
|
+
<input type="checkbox" id="checkbox1" checked>
|
318
|
+
|
319
|
+
Bを非表示(これをクリックしてBの列が全て消えるようにしたいです。)
|
320
|
+
|
321
|
+
</label>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
<table class="test" id="table1">
|
326
|
+
|
327
|
+
<tbody>
|
328
|
+
|
329
|
+
<tr>
|
330
|
+
|
331
|
+
<th>A</th>
|
332
|
+
|
333
|
+
<th colspan="2" id="addr1" class="th1 group1">B</th>
|
334
|
+
|
335
|
+
<th>C</th>
|
336
|
+
|
337
|
+
</tr>
|
338
|
+
|
339
|
+
<tr>
|
340
|
+
|
341
|
+
<td rowspan="2" class="waku">ぽぽぽ</td>
|
342
|
+
|
343
|
+
<td class="group1">ねこ</td>
|
344
|
+
|
345
|
+
<td class="group1">いぬ</td>
|
346
|
+
|
347
|
+
<td>ヤモリ</td>
|
348
|
+
|
349
|
+
</tr>
|
350
|
+
|
351
|
+
<tr>
|
352
|
+
|
353
|
+
<td class="group1">おうち</td>
|
354
|
+
|
355
|
+
<td class="group1">おにわ</td>
|
356
|
+
|
357
|
+
<td>おそと</td>
|
358
|
+
|
359
|
+
</tr>
|
360
|
+
|
361
|
+
</tbody>
|
362
|
+
|
363
|
+
</table>
|
364
|
+
|
365
|
+
<script>
|
366
|
+
|
367
|
+
document.getElementById("checkbox1").addEventListener("change", function () {
|
368
|
+
|
369
|
+
var elements = document.querySelectorAll(".group1");
|
370
|
+
|
371
|
+
if (!this.checked) {
|
372
|
+
|
373
|
+
for (var i = 0; i < elements.length; i++) {
|
374
|
+
|
375
|
+
elements[i].style.display = "none";
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
} else {
|
380
|
+
|
381
|
+
for (var j = 0; j < elements.length; j++) {
|
382
|
+
|
383
|
+
elements[j].style.display = "table-cell";
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
}, false);
|
390
|
+
|
391
|
+
</script>
|
392
|
+
|
393
|
+
</body>
|
394
|
+
|
395
|
+
</html>
|
396
|
+
|
397
|
+
```
|