const target = document.getElementById("target"); target.addEventListener('click', () => target.style.opacity = '0'); // If you want to remove it from the page after the fadeout target.addEventListener('transitionend', () => target.remove());