0

This is really confusing me. Everything runs smooth in Chrome and Safari, but I get an error in Firefox:

TypeError: currentButton is undefined

It lists the "index - currentButton" line as the source of the error. I'd love to know what I did wrong here! Hopefully this is enough code to track down the problem:

document.getElementById('buttons').addEventListener('click', function(e) {

var currentButton = e.srcElement,
    index = currentButton.getAttribute('data-index');
royhowie
  • 11,075
  • 14
  • 50
  • 67
i_made_that
  • 941
  • 1
  • 8
  • 19

1 Answers1

2

this should work:

document.getElementById('buttons').addEventListener('click', function(e) {

    var currentButton = e.target || e.srcElement,
            index = currentButton.getAttribute('data-index');
pwolaq
  • 6,343
  • 19
  • 45