0
box.style.left is show a error
Uncaught TypeError: Cannot read property 'style' of null
3 Antworten
+ 5
This happens because your code fails in retrieving the "box" element from your HTML.
That's all we know.
Please let us see your code.
https://www.sololearn.com/post/75089/?ref=app
If you are running your code in Sololearn remember that code within JS section is appended to the head tag:
https://www.sololearn.com/post/90825/?ref=app
😉 Krishna 🤘 You are right but that's not the only reason. This also happens when someone tries to get an unexisting element using document.getElementById /querySelector, etc. Just saying because you maybe didn't know
+ 2
Need to see that line of code which is showing error ,possibly you are trying to assign box.style.left to some variable which will results in null ,or others have already mentioned
+ 1
This happened because I forgot to use "window onload function."
Great Thanks to all of you to suggest my mistakes🔥🔥🔥