I'm trying to iterate over a list of <ul>
, so I have the code
let frost = document.createElement("ul");
let kiba = document.getElementsByTagName("li");
console.log(kiba);
for (todos of kiba) {
console.log(todos.style.color);
if (todos.style.color === `red`) { frost.appendChild(todos); }
}
for (todos of kiba) {
//console.log(todos);
if (todos.style.color === `black`) {frost.appendChild(todos);}
}
for (todos of kiba) {
//console.log(todos);
if (todos.style.color === `green`) {frost.appendChild(todos);}
}
let tasks = document.getElementById(`tasks`);
//for (i in todos) { tasks.appendChild(i); }
console.log(frost);
But it doesn't get to all the <li>
, only some. and I have no idea why.