Javascript animation box
Help me to get rid of the error please! Every time I get this error at the last line- 'style property cannot be null.' Here is my code: <!DOCTYPE html> <html> <head> <title>Animation-Box</title> </head> <body> <div id="container"></div> <div id="box"></div> </body> </html> #container{ width:300px; height:300px; background-color:#44DD55; position:relative; } #box{ width:30px; height:30px; background-color:#FFFFFF; position:absolute; } var pos = 0; var box = document.getElementById("box"); var t = setInterval(move, 20); function move() { if (pos >= 270) { clearInterval(t); } else { pos += 1; box.style.left = pos + "px"; } }