CSS animations emit events, so you can use the animationend event to intervene when the animation ends. const element = document.