I have a div, when I clicked on it, should turn all the elements in the .counter class to red, but at the moment it does nothing. I believe you have to run through a loop first
function handleClick() {
var myCounters = document.getElementsByClassName("counter")
for (var i = 0; i < myCounters.length; i++) {
myCounters[i].style.backgroundColor = "red"
}
}
.counter {
width: 100px;
height: 100px;
background-color: orange;
}
#btn {
background-color: aqua;
width: 50px;
height: 50px;
position: absolute;
left: 200px;
top: 10px;
}