Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to add eventlister to multiple variable

document.querySelectorAll('.some-class').forEach(item => {
  item.addEventListener('click', event => {
    //handle click
  })
})
Comment

how to add eventlister to multiple variable

[document.querySelector('.a-class'), document.querySelector('.another-class')].forEach(item => {
  item.addEventListener('click', event => {
    //handle click
  })
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: in compare method why we taking a and b for sorting in javascript 
Javascript :: js pass data between pages 
Javascript :: passport userlogin post method 
Javascript :: how to creacte react component 
Javascript :: js create a auto call function inside function 
Javascript :: ubuntu apps to install 
Javascript :: moment date format 
Javascript :: flutter inject javascript in flutter webview 
Javascript :: factorial program in javascript 
Javascript :: decode jwt token nodejs 
Javascript :: regex check for anchor tag with specific text 
Javascript :: how to pass props to another component 
Javascript :: update head tag metadata vue 
Javascript :: html video time 
Javascript :: how to update mongodb collection with a new field 
Javascript :: random message in discord.js 
Javascript :: update state in useState hook 
Javascript :: reverse string javascript 
Javascript :: input element change event data 
Javascript :: label animation css 
Javascript :: delete node between indexes node list js 
Javascript :: Iterate with JavaScript Do...While Loops 
Javascript :: react form validation 
Javascript :: fibonacci recursive method 
Javascript :: comparison operators in javascript 
Javascript :: list of string angular 
Javascript :: A better way to concatenate arrays 
Javascript :: unexpected token react 
Javascript :: convert js to python online 
Javascript :: how to update react app 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =