From a00caaf3947867905afa66ecf29d63ab4fc8cd3f Mon Sep 17 00:00:00 2001 From: Lu Wilson Date: Fri, 15 Dec 2023 00:06:22 +0000 Subject: [PATCH] Update index.html --- todo/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/todo/index.html b/todo/index.html index 4fc2b9e5..fecd693c 100644 --- a/todo/index.html +++ b/todo/index.html @@ -24,7 +24,7 @@ const main = document.querySelector("main"); const template = document.querySelector("template"); - const addItem = ({ done = false, text = "" } = {}) => { + const addItem = ({ done = false, text = "" } = {}, save = true) => { const fragment = template.content.cloneNode(true); const item = fragment.querySelector("p"); const button = item.querySelector("button"); @@ -34,12 +34,14 @@ const input = item.querySelector("input[type=text]"); input.value = text; main.append(item); + + if (save) saveItems() }; const loadItems = () => { const items = JSON.parse(localStorage.getItem("items")) ?? []; for (const item of items) { - addItem(item); + addItem(item, false); } };