javascript restart css animation
<style>
/* The element to apply the animation to */
div { animation: example 2s; }
/* animation keyframe */
@keyframes example {
0% { background-color: red; }
100% { background-color: blue; }
}
</style>
<!-- element example -->
<div id="aa">hello</div>
<!-- restart animation button -->
<button onclick="restart()">restary animation</button>
<script>
// restart function
function restart() {
document.getElementById("aa").style.animation = 'none';
setTimeout(() => {
document.getElementById("aa").style.animation = '';
}, 0);
}
</script>