From a87eb774e4f4c3d11c2c8374582c40b9333c0c6e Mon Sep 17 00:00:00 2001 From: Saurabh Kashyap <153047425+saurabhk9919@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:25:00 +0530 Subject: [PATCH] managed the linter --- index.html | 3 ++- script.js | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index d0452ef..2f901d5 100644 --- a/index.html +++ b/index.html @@ -74,7 +74,8 @@

Todo-List

diff --git a/script.js b/script.js index 12082a5..6034496 100644 --- a/script.js +++ b/script.js @@ -154,6 +154,18 @@ function cancelEditTodo() { addButton.appendChild(addIcon); } +const resetForm = () => { + // Get the input fields + const nameInput = document.querySelector('.js-name-input'); + const dateInput = document.querySelector('.js-date-input'); + const timeInput = document.querySelector('.js-time-input'); + + // Clear their values + nameInput.value = ''; + dateInput.value = ''; + timeInput.value = ''; +}; + function updateTodoList() { // Sort todoList based on the current sort method let filteredTodos = todoList; @@ -181,18 +193,6 @@ function updateTodoList() { : priorityOrder[b.priority] - priorityOrder[a.priority]; } }); - - function resetForm() { - // Get the input fields - const nameInput = document.querySelector('.js-name-input'); - const dateInput = document.querySelector('.js-date-input'); - const timeInput = document.querySelector('.js-time-input'); - - // Clear their values - nameInput.value = ''; - dateInput.value = ''; - timeInput.value = ''; - } const addElement = document.querySelector('.js-add-html'); todoListhtml = ''; @@ -231,6 +231,7 @@ function updateTodoList() { button.addEventListener('click', (event) => { const index = event.currentTarget.getAttribute('data-index'); deleteTodo(index); + resetForm(); }); });