I would like to use pure JS to add classes to some elements and am familiar with selecting the element with an ID, but when I've tried to use getElementsByClassName, my code breaks. Is it not possible to get elements by class name and add a new class?
I know the following code works, but, again, would like to target the element by className.
document.getElementById("id-name").classList.add("new-class");