0
move left top bottom right
what continue the script? and if I want to continue the movement //calling the function in window.onload to make sure the HTML is loaded window.onload = function() { var pos = 0; //our box element 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'; } } };
1 Réponse
0
dunno, is that what you want?
pos += 1;
box.style.left = pos+'px';
box.style.top = pos+'px';