JSFiddle - React, Tailwind, and code Playground
by ymutlu
HTML
<style>
#board { height:500px; width:500px; background-color: gray; position:relative;}
#ball{ height: 50px; width:50px; background-color: red; position:absolute;}
</style>
<div id="board">
<div id="ball"></div>
</div>
JavaScript
var ball = $("#ball");
var p = $("#ball").position();
//$("#ball").css("left", 10+p.left);
function moveBallDest(){
var p = $("#ball").position();
$("#ball").css("left", 10+p.left);
if ( p.left >= 400 ){
return;
}else{
setTimeout(moveBallDest,1000);
}
}
setTimeout(moveBallDest,1000);