Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takahirohonda/6f96784e64198a00b6e00c05ef1ee39d to your computer and use it in GitHub Desktop.
Save takahirohonda/6f96784e64198a00b6e00c05ef1ee39d 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