You might want to add a listener to an element, then remove the listener later. You don't want to remove the listener code entirely because then the listener won't fire during the interval you want it to.
const button = document.querySelector('button');
button.addEventListener('click', () => {
const listener = () => console.log('hovered');
button.addEventListener('mouseover', listener);
setTimeout(() => {
console.log('listener removed');
button.removeEventListener('mouseover', listener);
}, 2000);
});
<button>click to enable hover listener</button>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…