+ 6
How to modify all 3 elements
Can someone tell me why this thing didn't work : Supplies = document.getElementsByClassName ("supplie")[0]; Supplies.style.color="red"; It just color the first elements ==? if I have 3 elements how can I modified all 3 of it?
3 ответов
+ 4
because by id you said supplie and not supplies it doesnt know its an array. add the s and it should work just fine
+ 2
var supplies = document.getElementByClassName("supplie");
for (var x=0;x<supplies.length;x++) {
spplies[x].style.color="red";
}
+ 1
TRY THIS ONE
Supplies = document.getElementsByClassName ("supplies")[0];
Supplies.style.color="red";