By clicking on the first element, the animation = "move 5s"; style is added animation = "move 5s"; . How to get a callback at the end of css animation to nullify the style? You can drop the modifier in the form of a class that has styles, or it can be reset via an attribute and then reset, but how to get a callback ?
PS: For the sake of clarity, I reset the style via setTimeout .
function getId(id) { return document.getElementById(id); } function getStyle(elem) { return getComputedStyle(elem); } function setStyle(elem) { return elem.style; } let firstElem = getId("first"); firstElem.addEventListener('click', function() { setStyle(firstElem).animation = "move 5s"; setTimeout(function() { setStyle(firstElem).animation = "none"; }, 5000); }); body { background: #3B3738; padding: 10px; } .elem { position: relative; text-align: center; font-weight: bold; font-size: 18px; text-transform: uppercase; padding: 20px; background: #512; width: 150px; box-shadow: inset 0 0 0 1px #000; //animation: move 5s; left: 0; margin-bottom: 10px; &:not(:last-child) { margin-bottom: 10px; } } @keyframes move { 50% { left: 100%; transform: translateX(-100%); } } <div class="elem" id="first">First</div>