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
Post a Comment