Skip to content

Commit

Permalink
7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixtr committed Feb 4, 2024
1 parent f525e0c commit 346b827
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/js/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ const toDoForm = document.getElementById("todo-form");
const toDoInput = document.querySelector("#todo-form input");
const toDoList = document.getElementById("todo-list");

const toDos = [];

function saveToDos() {
localStorage.setItem("todos", JSON.stringify(toDos));
}

function deleteToDo(event) {
const li = event.target.parentElement;
li.remove();
Expand All @@ -23,7 +29,9 @@ function handleToDoSubmit(event) {
event.preventDefault();
const newTodo = toDoInput.value;
toDoInput.value = "";
toDos.push(newTodo);
paintToDo(newTodo);
saveToDos();
}

toDoForm.addEventListener("submit", handleToDoSubmit);

0 comments on commit 346b827

Please sign in to comment.