Without jQuery (or any library), how do I “name” an event so that I can detach just that event later. For example, I have 3 click events on one element:
target1.addEventListener(click, callback1, false);
target1.addEventListener(click, callback2, false);
target1.addEventListener(click, callback3, false);
I want to unbind just callback2. I’m NOT concerned with fallbacks. I know this is easy, but I CANNOT find any material on this outside of jQuery (maybe I’m using the wrong verbiage, idk).
You need to save your event listeners and then use them in:
element.removeEventListener(type, listener, useCapture)Why would you not use jQuery though?
The link below is the documentation + code samples:
https://developer.mozilla.org/en-US/docs/DOM/element.removeEventListener