diff --git a/src/index.ts b/src/index.ts index c79321f..ef72098 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,6 +62,7 @@ function addListItem(task: Task) { }); editbtn.addEventListener("click", function () { label?.focus(); + changeTask(item); }); } @@ -74,3 +75,20 @@ function loadTasks(): Task[] { if (taskJSON == null) return []; //if taskJSON is null, return to an empty array return JSON.parse(taskJSON); // if it's not null, return to the taskJSON. As : Task[] is written after func loadTasks(), it will specifically parse the array. Without it, it will parse anything } + +function changeTask(item) { + var changer = document.createElement("input"); + changer.className = "changer"; + var text = item.firstChild.innerHTML; + changer.value = text.replace('',""); + item.append(changer); + var button = document.createElement("button"); + button.innerHTML = "X" + item.append(button); + button.addEventListener("click", function (){ + item.firstChild.innerHTML = ''+ changer.value; + changer.remove(); + button.remove(); + + }); +}