innerHTML error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

innerHTML error

https://code.sololearn.com/WnIjN3PENLp7/?ref=app I can't figure out what is wrong with this code. It keeps spiting out an innerHTML error.

23rd Oct 2018, 9:51 PM
Jordan
Jordan  - avatar
6 Answers
+ 6
Do not use onclick function inlined to HTML tags. JavaScript codes should be on the JS tab only. You should separate them according to their placement.
24th Oct 2018, 11:47 AM
ᴰᴼᴹᴵᴺᴼ
ᴰᴼᴹᴵᴺᴼ - avatar
+ 4
Read here to understand why it happens and how to fix it https://www.sololearn.com/post/7444/?ref=app
23rd Oct 2018, 10:16 PM
Burey
Burey - avatar
+ 2
Upper Cast HTML
27th Nov 2018, 8:09 PM
Abdol Hashimi
Abdol Hashimi - avatar
+ 1
There are two ways to solve this, and I'll only give you hints. 1. What if document.getElementById doesn't work because the DOM hasn't loaded yet? Is the header variable working then? 2. What would happen if I used document.getElementById somewhere else in the code?
24th Oct 2018, 1:09 PM
Zeke Williams
Zeke Williams - avatar
24th Oct 2018, 3:05 PM
Jordan
Jordan  - avatar
0
Thanks so much. From my research, I gathered that it was a loading problem, but I wasn't sure how to fix it. This solves my problem.
23rd Oct 2018, 10:40 PM
Jordan
Jordan  - avatar