0
Why my code is showing error? Can anyone help me?
https://code.sololearn.com/WhfruagW81lB/?ref=app https://code.sololearn.com/WhfruagW81lB/?ref=app
3 Réponses
+ 3
window.onload = function(){
var pos=0; //starting position
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"; //px is pixels
}
}
}
+ 1
Dont run the javascript until the document is loaded therefore add your javascript in onload function.
window.onload = function(){
// your js code
}
0
Could you post your code after solving please?