var elements = document.getElementsByClassName("element"); for (var i = 0; i < elements.length; i++) { // do what you want with elements[i] }