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 @@ + + + + + + To-Do List + + + +
+

To-Do List

+
+ + +
+ +
+ + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..9e093c0 --- /dev/null +++ b/style.css @@ -0,0 +1,71 @@ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + margin: 0; + padding: 0; +} + +.container { + width: 300px; + margin: 50px auto; + background-color: white; + padding: 20px; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +h1 { + text-align: center; +} + +form { + display: flex; + justify-content: space-between; + margin-bottom: 20px; +} + +input { + width: 70%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 5px; +} + +button { + padding: 10px; + border: none; + border-radius: 5px; + background-color: #333; + color: white; + cursor: pointer; +} + +button:hover { + background-color: #555; +} + +ul { + list-style-type: none; + padding: 0; +} + +li { + display: flex; + justify-content: space-between; + padding: 10px; + border: 1px solid #ddd; + border-radius: 5px; + margin-bottom: 10px; +} + +li button { + border: none; + background-color: red; + color: white; + border-radius: 5px; + cursor: pointer; +} + +li button:hover { + background-color: darkred; +}