I have a function add_the_handler that binds an onclick event to each node. The following example prints "3" in every alert window, when I click on any node:
var add_the_handlers = function (nodes) {
var i;
    for (i=0; i< nodes.length; i+=1) {
        nodes[i].onclick = function (e) {
            alert(i);    
        };
    }
};
fiddle is here: http://jsfiddle.net/D886E/3/
Why doesn´t the nodes print the different values 1,2,3 in the alert windows?
 
    