JSFiddle - React, Tailwind, and code Playground
HTML
<span class="rightDiv">Here's some text</span>
CSS
.rightDiv {
background-color: red;
padding: 10px;
cursor: pointer;
position: absolute;
left: 50px;
}
JavaScript
$(document).ready(function() {
$(".rightDiv").attr("isLeft",1).click(function() {
var pos = "50";
if( $(this).attr("isLeft") == "1" ){
pos = "150";
$(this).attr("isLeft",0)
}else{
$(this).attr("isLeft",1);
}
$(this).stop(true).animate({left: pos + 'px'});
});
});