Answers for "how to apply an event on all classes"

10

how to apply an event on all classes

document.querySelectorAll('.some-class').forEach(item => {
  item.addEventListener('click', event => {
    //handle click
  })
})
Posted by: Guest on August-07-2020

Code answers related to "how to apply an event on all classes"

Code answers related to "Javascript"

Browse Popular Code Answers by Language