+1

Uncaught TypeError?

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

4/13/2019 12:25:35 AM

Glory S

3 Answers

New Answer

+3

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

0

https://code.sololearn.com/WriFNOoR188j/?ref=app https://code.sololearn.com/W8qiO41gHNfu/?ref=app