I have code akin to the following:
// Already existing: var my_elements - an array of elements.
for (var i = 0, len = my_elements.length; i < len; i++){
my_elements[i].oninput = function(){blue_background(my_elements[i])};
}
function blue_background(my_element){
my_element.style.backgroundColor = "blue";
}
The problem with this, however, as far as I can tell, as the array is looped through, by the time the event triggers, [i] is no longer an existing variable and I get an alert of "undefined".