+ 3

My code doesn't work on solo learn but works else where. Something i don't know about how this platform does its staff?

var myText = document.querrySelector("#text"); var myText = document.getElementById("text"); If i use one of the about, it shows some sort of error message Example: myText.style.color = "red"; I get this: Error: "Cannot read property 'style' of null"

23rd May 2019, 10:56 AM
Laban Paul
Laban Paul - avatar
3 odpowiedzi
+ 3
The only error I cans see in the code you've posted here is that querrySelector should be querySelector, however it's difficult to fully understand your error without showing the full code. Could you post it in Code Playground and share it here?
23rd May 2019, 11:20 AM
Rincewind
Rincewind - avatar
+ 2
Thanks for your feedback guys, i got a solution. window.onload worked just fine.
24th May 2019, 8:04 PM
Laban Paul
Laban Paul - avatar
+ 2
I guess it had something to do with the script running before the being loaded by the DOM
24th May 2019, 8:07 PM
Laban Paul
Laban Paul - avatar