Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takahirohonda/4c34728d0cb2cc173deaf3486c5cc022 to your computer and use it in GitHub Desktop.
Save takahirohonda/4c34728d0cb2cc173deaf3486c5cc022 to your computer and use it in GitHub Desktop.
better-way-to-attach-event-listener-with-vanilla-js-3-loop-way.js
const radioInputs = document.querySelectorAll('.radio-input')
for(let input of radioInputs) {
input.addEventListener('change', e => {
console.log(`${e.target.value} is picked`)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment