+ 1
I have been stuck on this question can anyone help me?
var s = document. getElementsByTagName("span"); for(var x=0; x<s.length;x++) { s[_].style.backgroundColor = "#33EA73"; }
3 Respostas
+ 1
Just replace s[_] with s[x]
One tips : actually it's a bad practice to compute length on every iteration
Better idea is to cache it. Find below the code snippet for for-loop
for(var x = 0, l = s.length; x < l; x = x + 1){
s[x].style.backgroundColor = "#33EA73";
}
0
Never mind i just figured it out
0
Ok