Not all browsers support forEach on NodeLists, but for those that do: buttons.forEach((button) => { button.addEventListener('click', () => { console.log("forEach worked"); }); }); bit deeper browser support. var divs = document.querySelectorAll('div'); [].forEach.call(divs, function(div) { // do whatever div.style.color = "red"; });