Answers for "give event listener to multiple elements at once in jquery"

11

add event listener to multiple element in JS

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

how to add the click event into two element in jquery

$('.class1').add('.class2').on('click', some_function);
Posted by: Guest on January-29-2021

Code answers related to "give event listener to multiple elements at once in jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language