How can I add an event listener to each element in a NodeList?
var items = document.getElementsByClassName('productLnk');
function myFunction(element, index, array) {
element.addEventListener('click', function() {
alert('Hello!');
});
}
Array.prototype.forEach.call(items, myFunction);
However, I am getting an error that says "test.forEach is not a function". How can I resolve this issue?