bind click event for all buttons:
for (var i = 0; i < buttons.length; i++) { var button = buttons[i]; if (button.addEventListener) { button.addEventListener('click', handler, false); } else { button.attachEvent('onclick', handler); } }
in the event handler, get the Event object, and then get the target:
function handler(e) { e = e || window.event;
source share