addEventListener("load", () => { const onAnimationFinished = (e) => { e.target.remove(); }; const onClick = (e, btn) => { const clickElement = document.createElement("div"); clickElement.className = "click"; clickElement.addEventListener("animationend", onAnimationFinished); btn.appendChild(clickElement); }; for (const btn of document.getElementsByClassName("btn")) { btn.addEventListener("focusin", () => { console.log("IN"); }); btn.addEventListener("focusout", () => { console.log("OUT"); }); btn.addEventListener("click", (e) => onClick(e, btn) ); }; });