The situation is somewhat like-
var someVar = some_other_function(); someObj.addEventListener(\"click\", function(){ some_function(someVar); }, false); <
The following code worked fine for me (firefox):
for (var i=0; i<3; i++) { element = new ... // create your element element.counter = i; element.addEventListener('click', function(e){ console.log(this.counter); ... // another code with this element }, false); }
Output:
0 1 2