"addEventListener" is not working on this... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

"addEventListener" is not working on this...

If you know why tell me...

23rd May 2022, 2:16 PM
AmeenSid
AmeenSid - avatar
3 Answers
+ 3
You need to ensure that the html is loaded before you try to get an html element in Javascript. Put all your Javascript inside window.onload: window.onload = () => { // your code }
23rd May 2022, 2:29 PM
Lisa
Lisa - avatar
+ 1
Can you share the code where you're experiencing the error?
23rd May 2022, 2:21 PM
Justice
Justice - avatar
23rd May 2022, 2:24 PM
AmeenSid
AmeenSid - avatar