+ 1
Uncaught TypeError?
it said Uncaught TypeError: Cannot read property 'addEventListener' of null Line: 3 https://code.sololearn.com/WZt0O6ZdvL8o/#html
3 odpowiedzi
+ 5
Glory S its too common error beginner gets here.
Its just that your JS gets loaded before the html window and hence it cannot find the html element you're adding eventListener to thus its null.
You need to warp you JS code inside a function which will be called once the html window gets loaded.
You can do it like
window.onload =function () {
//your JS code goes here
}
+ 1
Thank you bro