I'm attaching listener to all the children of a div, how to make them to alert with their number relative to their parent. Because the function executes the actual variable i, not when attached.
var nodes = div.children; //10 nodes
for (var i = 0; i < nodes.length; i++) {
nodes[i].onclick = function () {alert(i)}
}
So the only solution is to use eval('i')?