Div onload wont drop down
I'm trying to make the div slowly drop down when the page loads to 100px lower using setInterval but it's not working for some reason. HTML: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body onload="dropbox"> <div class="container"></div> </body> </html> CSS: .container { width:100px; height:100px; background-color:purple; } Javascript: function dropbox(){ var p=0; var t=setInterval(drop,10); var box=document.getElementsByClassName('container'); function drop(){ if(p>=100){ clearInterval(t); } else{ p+=1; box[0].style.top=p+"px"; } } } Please Help! What am I doing wrong?