I am getting two different bugs

时间:2019-01-09 22:02:19

标签: javascript

I am getting this error after running debugger failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.

I am trying to insert a delete button into the DOM each time I add in a new to do item.

The delete button will be right next to the item created. hence why I am inserting it right into <li></li>

let view = {
 displayTodos: () => {
    let todoUl = document.querySelector('ul')
    todoUl.innerHTML = ''

 for (let i = 0; i < todoList.todos.length; i++) {
    let todoLi = document.createElement('li')
    todoLi.textContent = todoList.todos[i].todoText
    todoUl.appendChild(todoLi)
    let todo = todoList.todos[i]
    let todoTextCompleted = ''

    if (todo.completed === true) {
        todoTextCompleted = '✅' + todo.todoText 
        todoTextCompleted = '❌'  + todo.todoText 
    }
    debugger;
    todoLi.textContent = todoTextCompleted
    todoLi.appendChild(this.createDeleteButton)
    todoUl.appendChild(todoLi)
    }
 },
 createDeleteButton:() => {
    let deleteButton = document.createElement('button')
    deleteButton.textContent = 'DELETE '
    deleteButton.className = 'DeleteButton'
    return deleteButton
 }
}

0 个答案:

没有答案