Quiero poder configurar addEventListener para que se desasocie después del primer evento, en función de un condicional relacionado con el evento.
Quiero algo como;
var thing = document.querySelector('.thing'); thing.addEventListener('click',function(e){ if (e.pointerType === 'mouse'){ this.addEventListener.options.once = true; } }); <a class="thing">Thing</a>Desea usar removeEventListener . Puedes hacerlo así:
function handler(event){ if (event.pointerType === 'mouse'){ this.addEventListener.options.once = true; var targetElement = event.target || event.srcElement targetElement.removeEventListener("click", handler); } } var thing = document.querySelector('.thing'); thing.addEventListener('click',handler);