I have multiple input
fields assigned to a particular classname. Now I want to fetch the index of the classname of the input
field and console.log()
it.
This is my code:
document.querySelectorAll('.class-name').forEach(item => {
item.addEventListener('change', event => {
console.log(item); //print the index of the item
})
})
How can I do that? Please help me.