When a user clicks a button out of a series of buttons, I'd like the browser to be able to detect which buttons are toggled as soon as they've clicked it.
Here's an example: http://jsfiddle.net/Uc6LV/11/
I changed the event listener from click
to mouseup
but it still seems to fire the event too early.
Any ideas?
In your event listener, I would listen for a "click" event and delay the actual calculation via setTimeout(). This works in your fiddle:
container.children[i].addEventListener("click", //click is better than mouseup
function(){
//let's delay execution until button is toggled
setTimeout(function() {
notice.innerHTML = toggled().toString(); }, 1);
})