I'm trying to target a list of elements using a for loop:
for(var i = 1; i < 5; ++i){
console.log(i)
target[i].classList.remove('redText')
anchor[i].classList.remove('redText')
}
The expected result is:
target1.classList.remove('redText')
anchor1.classList.remove('redText')
target2.classList.remove('redText')
anchor2.classList.remove('redText')
....etc.
in the console I get
ReferenceError: target is not defined
Which means the index is not being appended to target and anchor.
Is this possible to accomplish?
targetis referencing a collection of DOM elements or make suretargetis declared in your code.