<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#box {
height: 50px;
width: 50px;
border: 2px solid red;
position: absolute;
}
</style>
</head>
<body>
<div id="box"></div>
<script>
var el = null;
var el = document.querySelector('#box')
el.style.left = '50px'
moveRight()
function moveRight() {
if (parseInt(el.style.left) > 900) {
el.style.left = 0;
}
el.style.left = parseInt(el.style.left) + 6 + 'px'
setTimeout(moveRight, 25)
}
</script>
</body>
</html>