Why it's not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
3rd Apr 2022, 11:21 PM
Anish Singh
2 Answers
+ 2
Just wrap your whole JS code in - window.onload = () => { ... }
4th Apr 2022, 1:42 AM
Arnav Gumber
Arnav Gumber - avatar
+ 1
You are selecting element before thay are rendered on screen, so nothing heppend (not sure why error dont exist) So place your code inside script at bottom of page, or use window.onload. Here is some example of window.onload in action, you can also wrap your full javascript code and it will work https://code.sololearn.com/WH0xv85NMI89/?ref=app
3rd Apr 2022, 11:29 PM
PanicS
PanicS - avatar