I try to add a class called "finished" as soon as an event is fired. I'm trying to achieve this with classList.toggle() but somehow, it doesn't work. Here's my code:
let checked = document.getElementsByClassName("single-note");
checked.classList.toggle("finished");
Testing it in the console, checked works and gives me back the elements. But toggle doesn't add any classes, it shows "Uncaught TypeError: Cannot read property 'toggle' of undefined". I also already tried it with .add and .contains, but this doesn't work either, giving me the same error message. I know it must have something to do with classList, but I don't know what I'm missing out.