JSFiddle - React, Tailwind, and code Playground
HTML
<div id = 'test'></div>
CSS
#test {
width: 50px;
height: 50px;
background: red;
position: relative;
}
JavaScript
var a = $('#test');
var x = 0;
var n = -5
function animate() {
if (!x || x == 300) {
n = -n;
}
x = x + n;
a.offset({left:x});
}
setInterval(animate,10);