0

For some reason I keep getting;

Type-error: cannot set properties of undefined (setting, 'display')

Any ideas? code below TIA

function filterTodo(e) {
 const todos = todoList.childNodes;
 todos.forEach(function(todo) {
   switch (e.target.value) {
     case "all":
       todo.style.display = "flex";
       break;
     case "completed":
       if (todo.classList.contains("completed")) {
         todo.style.display = "flex";
       } else {
         todo.style.display = "none";
       }
       break;
     case "uncompleted":
       if (!todo.classList.contains("completed")) {
         todo.style.display = "flex";
       } else {
         todo.style.display = "none";
       }
   }
 });
}
  
  • where is todoList declared? – DCR Sep 15 '21 at 19:23
  • Use `children` instead of `childNodes`. `childNodes` includes text nodes, which don't have a `style` property. – Barmar Sep 15 '21 at 19:24
  • TodoList is declared on the document didn't put it in as had no issues with the declaration until now, I will try that now Barmer. Thank you fingers crossed! – ConnorS1702 Sep 15 '21 at 19:26

0 Answers0