+ 1
Could someone help me?
Why is the background of this page not red? Instead it causes "Uncaught TypeError" and "Cannot read property 'style' of undefined." What did I do wrong? https://code.sololearn.com/WM2Uy2rn7SM8/?ref=app
2 Réponses
+ 7
https://code.sololearn.com/WP4ET66OwlVV/?ref=app
+ 5
The reason is because the element you're trying to access isnt yet created when the code run.
As you can see from Rstar example, the code need to run after the page loaded using onload listener. Other method is write the script at the bottom part of the body.