Get all elements with the same class
arrays, class, javascript
Solution
Method `getElementsByClassName()` returns a set of DOM elements that have a certain class name. Here is a canonical example of how to use the returned list of nodes:
var elements = document.getElementsByClassName("class-1");
for (var i = 0, len = elements.length; i < len; i++) {
// elements[i].style ...
}
Problem
I know that this: ``` document.getElementsByClassName('class-1')[0]. ``` selects the first `<div>` that has the specify class. I guess using a `for()` will get through the whole array of `<div>`. Can somebody explain how to create that array ? I will prefer plain Js.