I'd like to modify all classes with JS. Is there way to select them without manually setting the array index (for example [0] or [1] or [184])?
Example code:
<div class='message'>something:</div>
<div class='message'>something</div>
const element = document.querySelectorAll(".message");
element.classList.add("color");
It works only when I add [0]
and only for the first element that has the class.
But I'd like to modify all the elements with the class.