Javascript loop through DOM

I have 10 of these divs, with class names one through ten.

<div class="one"></div>

Is there an easy way to create a Javascript loop to do this for each div?

const one = document.getElementsByClassName('one')[0]; 
one.style.backgroundImage='url(/images/items/' + year + '/1.jpg)';


from Recent Questions - Stack Overflow https://ift.tt/3jjhYNU
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation