JSFiddle - React, Tailwind, and code Playground

HTML

<div class="test" id="test"></div>
<button onclick="move();">Move</button>

CSS

.test {
    position:absolute;
    background:blue;
    width:200px;
    height:200px;
    top:40px;
    transition:all 1s linear;
}
.moved {
    margin-right:60px;
    background:red;
}

JavaScript

window.move = function() {
    if($('#test').hasClass('moved')) {
        $('#test').removeClass('moved');
    }else{
        $('#test').addClass('moved');
    }
}