I searched for several questions here bt couldn't find the answer. The accepted answer removeEventListener without knowing the function only works in chrome and that too in non strict mode.
I have three functions. One to attach event listeners to elements using selectors and another to remove event listeners from the element and the third one to remove all event listeners from the page.
The functions are something like:
function listen(node, event, callback, options)
{
node.addEventListener(event, callback, options);
}
removeAllListeners(node)
{
}
removeListener(node, event)
{
}
The user can pass any type of callback functions to the function which attaches the listener. How do I go about removing the event listeners.
I do not want to use any third party library as well.
Tried:
var eventlistener = getEventListeners(window)["DOMContentLoaded"][index];
window.removeEventListener("DOMContentLoaded", eventlistener.listener, eventlistener.useCapture);
but only works on chrome and that too only in non strict mode.