From ec93ad49ff33730d6676983162bf5157f14d32f8 Mon Sep 17 00:00:00 2001 From: Abdul Hai <153994789+abdulhai123456789@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:01:18 +0500 Subject: [PATCH] first commit --- app.js | 26 ++++++++++++++++++++ index.html | 20 +++++++++++++++ style.css | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 app.js create mode 100644 index.html create mode 100644 style.css diff --git a/app.js b/app.js new file mode 100644 index 0000000..e7b9462 --- /dev/null +++ b/app.js @@ -0,0 +1,26 @@ +document.addEventListener('DOMContentLoaded', () => { + const form = document.getElementById('todo-form'); + const todoInput = document.getElementById('new-todo'); + const todoList = document.getElementById('todo-list'); + + form.addEventListener('submit', (e) => { + e.preventDefault(); + const newTodoText = todoInput.value.trim(); + if (newTodoText !== '') { + addTodoItem(newTodoText); + todoInput.value = ''; + } + }); + + function addTodoItem(text) { + const li = document.createElement('li'); + li.textContent = text; + const deleteButton = document.createElement('button'); + deleteButton.textContent = 'Delete'; + deleteButton.addEventListener('click', () => { + todoList.removeChild(li); + }); + li.appendChild(deleteButton); + todoList.appendChild(li); + } +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..88238f2 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + +
+ + +