My code isn't working, please help!
Hi. So I tried to do this code following the animation tutorial but it doesn't move. It gave me the error message: Uncaught TypeError: Cannot read property 'style' of null at move (VM27 tutorial5.html:17) Here is the code: HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <link rel="stylesheet" type="text/css" href="stylesheet1.css"> <title>JS Tutorial - Creating Animation With setInterval();</title> <script type='text/javascript'> var pos = 0; var box = document.getElementById('box'); var t = setInterval(move, 10); function move() { if(pos >= 150){ clearInterval(t); } else { pos +=1; box.style.left = pos+"px"; } } </script> </head> <body> <div id="container"> <div id="box"></div> </div> </body> </html> And here is the CSS: #container { width: 200px; height: 200px; background: green; position: relative; } #box { width: 50px; height: 50px; background: red; position: absolute; } Thank you!