Echoing the “then” state of variable in a mootools event even after var has changed
问题 Let's take some pseudo-Mootools code: for loop (i) from 0 to 5 { create.element { id: 'element_'+i } $('element_'+i).addevent.click { alert(i); } } The events get added to the elements properly. However, when clicked, they'll all alert the latest iterator... which would be 5. Is there any way I can change "alert(i)" in the event to alert the iterator at that point in time? .toString didn't do much. 回答1: http://www.jsfiddle.net/dimitar/sbytJ/1/ for (var ii = 0; ii < 5; ++ii) { new Element("div