I'm trying to add a new class to a given class without using GetElementById. My project has an array on the list, and each list creates dynamic classes like 0-test, 1-test, 2-testing, so on. Add a new class to a given class like ( 0-test active-test) class. I am trying to have some javascript properties, but it is not working properly. My code is:-
document.getElementsByClassName('0-test')[0].className += "active-test";
It's not working please tell me how to add a new class?