how can i remove this event listener I have tried but below code and it does not seam to bare any fruit
class Tag {
constructor(name){
this.tag = document.createElement(name);
}
removeEvent(e,func){
this.tag.removeEventListener(e,func,false);
}
addEvent(e,func) {
this.tag.addEventListener(e,func,false);
}
}
let tag = new Tag();
tag.addEvent('click',(e)=> {
console.log('something');
});
How do I get the removeEvent to work? please help I specifically need how to reference the anonymous function since this works.
function handler(e){
// code for event
}
tag.addEventListener('click',handler,false);
tag.removeEventlistener('click',handler,false);
I have tried adding
removeEvent(e,func) {
func.ref = function (){
return arguments.callee;
}
this.tag.removeEventListener(e,func.ref,false);
}
Just doesn't work given now we would be referring to func.ref as the function reference;