Styling in JS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Styling in JS

I get the error null is not an object and I can’t find any post with this issue. What is it? https://code.sololearn.com/Wq9DGR4zc083/?ref=app

7th Jan 2019, 6:24 PM
Korijn Jagersma
Korijn Jagersma - avatar
2 Answers
+ 5
Korijn, You declared the variable outside and underneath the function. The variable wont be recognized since it is declared after the function. Declare the variable inside the function to fix your issue. If you declare it to be global it is nessecary to initialize the DOM first since SL uses the script between the head tags instead of the bottom of the body Have a look at the changes👍 https://code.sololearn.com/WX60qm7IFBbn/?ref=app
7th Jan 2019, 6:34 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 1
Thanks, I understand now
7th Jan 2019, 6:39 PM
Korijn Jagersma
Korijn Jagersma - avatar