This is basically a followup question to this: Can't pass event to addEventListener: closure issue.
I have read almost every related question and can\'t find the
You have to keep references to your listeners:
var listeners = {};
for(/* ... */) {
(function outerfunction(i, f) {
var listener = function(e) {
responsefunction(e, f, i);
}
elementname.addEventListener("click", listener);
listeners[elementname.id] = listener; // use something meaningful
// as your keys
})(parameter1, parameter2);
}
// Removing the listener later:
elementname.removeEventListener("click", listeners[elementname.id]);