I have a page with 5 input fields. How do I add a blur event listener on them together?
I get an error when I try
document.querySelectorAll('input').addEventListener('blur', e => {
console.log('blur on input')
})
EDIT 1
I am able to add eventListeners to individual items like so,
const allInputs = [...document.getElementsByTagName('input')]
allInputs.forEach(item => item.addEventListener('blur', (e) => console.log('blur') ))
But is there a way to add a collective event listener on HTMLCollection?