JSFiddle - React, Tailwind, and code Playground
HTML
<div class="box">
<img id="move" src="http://placekitten.com/200/300" alt="Pic" />
</div>
CSS
.box img {
margin-left:0;
-webkit-transition: 1s;
transition: 1s;
}
JavaScript
(function () {
var move = document.getElementById('move');
move.onclick = function () {
if (move.style.marginLeft === "500px") {
move.style.marginLeft = "0";
} else {
move.style.marginLeft = "500px";
}
};
})();