dear esteemed javascript gurus.
consider the following fragment:
var buttons =
document.getElementById("tr_Toolbar").getElementsB yTagName("button");
for (var i=0; i<buttons.length; i++) {
var button = buttons[i];
button.onmouseup = function() { mouseup(button.id); return false; }
}
during this loop, button.id is correctly returned as the id of the
button being processed, and all the buttons are assigned a mouseup
event. however, whichever button is clicked, the mouseup function is
always invoked with the id of the last button in the list.
I guess it's because the "button.id" in the function definition is
being evaluated at the wrong time.
I have found that in my particular case I can use "this.id" instead.
but can someone explain how "button.id" is evaluated in the context of
the code fragment above.
TIA
Andy