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'; } } };

12th Oct 2016, 11:43 AM
Nicola Lacerenza
Nicola Lacerenza - avatar
1 ответ
0
dunno, is that what you want? pos += 1; box.style.left = pos+'px'; box.style.top = pos+'px';
21st Nov 2016, 10:43 PM
Ed Magalhaes
Ed Magalhaes - avatar