I have the following problem.
I generate a list with all the elements with a specific class. After that i'm looping throug them to replace the class.
As you can see here: https://jsfiddle.net/nafxLoLz/ only one of the 2 elements get replaced. The console.log clearly shows that the loop only goes through once. If I comment the 7 javascript code out. (See the fiddle) the loop works fine.
What did I do wrong?
Code:
var list = document.getElementsByClassName("default");
console.log(list.length);
for(var i = 0; i < list.length; i++)
{
console.log(i);
list[i].classList.add("red");
list[i].classList.remove("default");
}