For example, if I want to loop through my page for all items with the class name “red” and change the background color of these items to red, i would simply do the following:
var redItems = document.getElementsByClassName("red");
for (var i = 0; i < redItems.length; i++)
var redItem = redItems[i];
redItem.style.backgroundColor = "#FF0000";
note: be sure to put this code at the bottom of your web page, otherwise the items with this class will not have rendered and it will not find them.