質問編集履歴

1

文法の追加修正

2021/07/04 08:01

投稿

You
You

スコア52

test CHANGED
File without changes
test CHANGED
@@ -389,3 +389,47 @@
389
389
  tbl.innerHTML = ""; を tbl.innerHTML = '';に変更した。
390
390
 
391
391
  ```
392
+
393
+
394
+
395
+ The web page successfully displays the time.
396
+
397
+
398
+
399
+ If this does not solve the error for you, make sure that you correctly select the element that you want to work with in your code. For instance, consider this line of code:
400
+
401
+
402
+
403
+ var show_time = document.getElementById("show_times");
404
+
405
+ If we used this line of code to select our element, we would see the same error that we encountered before. This is because there is no element whose ID is “show_times”.
406
+
407
+
408
+
409
+ Conclusion
410
+
411
+ The “Uncaught TypeError: cannot set property ‘innerHTML’ of null” error is caused by trying to set an innerHTML value for an element whose value is equal to null.
412
+
413
+
414
+
415
+ To solve this error, make sure your <script> tag comes after the element that you want to select in your script. If this does not solve the issue, check to make sure you are selecting a valid element in your program.
416
+
417
+
418
+
419
+ [出典](https://careerkarma.com/blog/javascript-cannot-set-property-innerhtml-of-null/)
420
+
421
+
422
+
423
+ ```js
424
+
425
+ let tbl = document.getElementById('calendar-body');
426
+
427
+ ```
428
+
429
+ ```html
430
+
431
+ <tbody class="calendar__body" id="calendar-body"></tbody>
432
+
433
+ ```
434
+
435
+ エレメントの指定も正しいことを確認済み。