diff --git a/src/index.js b/src/index.js index 08c71b311..bf4edf064 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,20 @@ document.addEventListener("DOMContentLoaded", () => { - // your code here -}); + let form = document.getElementById('create-task-form') + form.addEventListener('submit', event => { + event.preventDefault() + handleToDo(); + +}) +}) + +function handleToDo() { + let searchBoxValue = document.getElementById("new-task-description").value + let listItem = document.createElement('li') + let deleteBtn = document.createElement('button') + listItem.textContent = searchBoxValue + deleteBtn.textContent = ' X ' + document.getElementById("tasks").appendChild(listItem).appendChild(deleteBtn) + + deleteBtn.addEventListener('click', () => listItem.remove()) +} +