0 points

Loop Over querySelectorAll Matches


dashboard

Tue Jun 23 2020 08:44:22 GMT+0000 (UTC)

Posted by @Amna #javascript

buttons.forEach((button) => {
  button.addEventListener('click', () => {
    console.log("forEach worked");
  });
});
content_copy Copy

Not all browsers support forEach on NodeLists, but for those that do:

https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/