I made a List of buttons of class 'bol':
const bollen = document.querySelectorAll('button.bol');
With console.log(bollen) I get: [button.bol.bolkleur, button.bol.bolkleur, button.bol.bolkleur, button.bol.bolkleur]
I make a click event listener and want to know what is the index in the list of the item that I clicked but get the error : Uncaught TypeError: bollen.indexOf is not a function. But I don't understand why because I have seen examples that seem the same. My code is the following:
bollen.forEach(function (bol) {
bol.addEventListener('click', function (e) {
const gekozenBol = bollen.indexOf(bol);
console.log(`gekozen bol is ${gekozenBol}`);
});
});
Who can help me see what I do wrong? I am limited to a set of code because the project have to be made with things we have learned. Thankyou