News for hackers. Stuff that matters.
Re:JavaScript Interview Question by archgoon on Thursday January 20, 2011 @01:05PM (#2124563)
That won't work either. You're still setting the variable to the global variable i. The only way I can think of doing this is as follows

els[i].addEventListener('click',function(k){function(){alert(k)}}(i));

EDIT: See lhorie's suggestion below for a much cleaner way of doing this. http://news.ycombinator.com/item?id=2124532

There are no comments on this comment yet.