(event)
| 8 | todoList.addEventListener('click', deleteTodo); |
| 9 | |
| 10 | function addTodo(event){ |
| 11 | //prevent the form from submitting |
| 12 | event.preventDefault(); |
| 13 | |
| 14 | //add todo only when user enters something |
| 15 | if(todoInput.value !== ''){ |
| 16 | |
| 17 | //create wrapper div |
| 18 | const todoDiv = document.createElement('div'); |
| 19 | todoDiv.className = 'todo'; |
| 20 | |
| 21 | //create list element |
| 22 | const newTodo = document.createElement('li'); |
| 23 | newTodo.className = 'todo-item'; |
| 24 | newTodo.innerText = todoInput.value; |
| 25 | |
| 26 | //add that list element inside of wrapper div |
| 27 | todoDiv.appendChild(newTodo); |
| 28 | todoInput.value = ''; |
| 29 | |
| 30 | //create complete task button |
| 31 | const completedBtn = document.createElement('button'); |
| 32 | completedBtn.innerText = `✔️`; |
| 33 | completedBtn.classList.add('complete-btn'); |
| 34 | todoDiv.appendChild(completedBtn); |
| 35 | |
| 36 | //create trash button |
| 37 | const trashBtn = document.createElement('button'); |
| 38 | trashBtn.innerText = `❌`; |
| 39 | trashBtn.classList.add('trash-btn'); |
| 40 | todoDiv.appendChild(trashBtn); |
| 41 | |
| 42 | //Add wrapper div to ul |
| 43 | todoList.appendChild(todoDiv); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | function deleteTodo(e){ |
| 48 | const item = e.target; |
nothing calls this directly
no outgoing calls
no test coverage detected