10th Dec 2019, 5:07 PM
B Ricks
B Ricks - avatar
2 Answers
+ 1
getElementsByClassName() returns an array of all elements with the passed class name. In order to apply style to those elements, you have to access them individually. const blocks = document.getElementsByClassName("block"); for (let i = 0; i < blocks.length; i++) { blocks[i].style = ... }
10th Dec 2019, 5:19 PM
Russ
Russ - avatar
0
thanks, Russ!
10th Dec 2019, 5:39 PM
B Ricks
B Ricks - avatar