Listen for mouse over, change class
Iâm trying to work out a way to 1. Look for a class 2. Add an event listener on that class 3. When the mouse enters the div, toggle a new class? Iâve tried many varied ways, none successful! The below feels to be the closest. However, I either trigger an error that class Is null, or that the class EventListener Is not a function? My current code is: function animateCSS(changeClass, animationName, callback) { document.querySelectorAll(âdiv.projectâ) changeClass.classList.toggle('fadeIn') function handleAnimationEnd() { changeClass.classList.remove('fadeIn') changeClass.removeEventListener('animationend', handleAnimationEnd) if (typeof callback === 'function') callback() } changeClass.addEventListener('animationend', handleAnimationEnd) }