add multiple event listeners
Example of looping through an array of objects and adding click event listeners.
var itemsArray = document.querySelectorAll('.item');
itemsArray.forEach(function(item){
item.addEventListener('click', function(){
console.log(item);
});
});
copy