Answers for "set an on event funciton for all elements with class"

11

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 "set an on event funciton for all elements with class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language