Does NodeList support addEventListener. If not what is the best way to add EventListener to all the nodes of the NodeList. Currently I am using the code snippet as show be
in es6, you can do a array from nodelist, using Array.from, e.g.
ar_coins = document.getElementsByClassName('coins');
Array
.from(ar_coins)
.forEach(addEvent)
function addEvent(element) {
element.addEventListener('click', callback)
}
or just use arrow functions
Array
.from(ar_coins)
.forEach(element => element.addEventListener('click', callback))