JSFiddle - React, Tailwind, and code Playground

HTML

<div id="ball">ball</div>
<div id="dice">dice</div>

JavaScript

var ball = document.getElementById('ball');
var dice = document.getElementById('dice');
ball.style.position = 'absolute';
ball.style.left = '299px';
ball.style.top = '200px';
function move() {
  alert(ball.style.left + ' --- ' + ball.offsetLeft);
    if(ball.offsetLeft < 300){
     ball.style.left = '200px';   
    }

}

dice.onclick = move;