0
Issue with HTML running after JS
I'm working on a program and I had my HTML and JS on separate tabs but then I ran it, it showed me this error message: Uncaught TypeError: Cannot set property 'innerText' of null. So I went to Stackoverflow, and there said because HTML has to run first, so in the HTML tab, I made the <script> tags and put my JS their and worked. But shouldn't it work inside the JS tab too, because I would like for it to be external JS.
3 Answers
+ 2
Put your JS in the following function.
window.onload = ()=> {
JS here...
}
+ 4
https://www.sololearn.com/post/90825/?ref=app
By the way almost every new user will face that problem.
This question have been asked several times(too much) before because of that.
Using the search bar before posting questions will help the community by avoiding duplicates. Please take it into account the next time.
https://www.sololearn.com/discuss/612424/?ref=app
https://www.sololearn.com/discuss/259009/?ref=app
https://www.sololearn.com/discuss/1629118/?ref=app
https://www.sololearn.com/discuss/1469777/?ref=app
https://www.sololearn.com/discuss/139237/?ref=app
https://www.sololearn.com/discuss/1626865/?ref=app
https://www.sololearn.com/discuss/5067/?ref=app
https://www.sololearn.com/discuss/1218303/?ref=app
https://www.sololearn.com/discuss/1067840/?ref=app
https://www.sololearn.com/discuss/149523/?ref=app
https://www.sololearn.com/discuss/1675746/?ref=app
https://www.sololearn.com/discuss/261854/?ref=app
https://www.sololearn.com/discuss/2171295/?ref=app
+ 1
Thanks that fixed the problem!