Uncaught TypeError? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Uncaught TypeError?

it said Uncaught TypeError: Cannot read property 'addEventListener' of null Line: 3 https://code.sololearn.com/WZt0O6ZdvL8o/#html

13th Apr 2019, 12:25 AM
Glory222
Glory222 - avatar
3 Respostas
+ 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 }
13th Apr 2019, 12:31 AM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar
+ 1
Thank you bro
13th Apr 2019, 2:16 AM
Glory222
Glory222 - avatar