Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add eventlister to multiple variable

[document.querySelector('.a-class'), document.querySelector('.another-class')].forEach(item => {
  item.addEventListener('click', event => {
    //handle click
  })
})
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #add #eventlister #multiple #variable
ADD COMMENT
Topic
Name
7+4 =