I am starting to learn to develop in html, css and javascrip and I was applying the example of “requestAnimationFrame” to an exercise I’m doing to understand more. but when I run the code I get an error like this:
“Uncaught TypeError: Can not read property ‘style’ of null”
mover.css (233 Bytes)
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="mover.css" />
This line is where the problem is:
var element = document.getElementById("thing");
element variable is set to null. The reason probably has to do with your code running before the full DOM has loaded. You can fix this by putting your
script tag at the bottom of the page just above the closing
body tag. You can learn more about other approaches you can take at the following tutorial: https://www.kirupa.com/html5/running_your_code_at_the_right_time.htm
Let me know if that change fixes it for you
thank you Kirupa for the answer soon, really appreciate that. about your advice its works I did the change and is working finally I will could keep study.
thanks a lot.