Skip to content

Commit f4fcb36

Browse files
committed
TODOApp
1 parent 897dcf1 commit f4fcb36

3 files changed

Lines changed: 68 additions & 0 deletions

File tree

ToDoApp/css/todo.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
.container{
3+
4+
display: flex;
5+
flex-direction: column;
6+
align-items: center;
7+
justify-content: center;
8+
height: 80%;
9+
width: 75%;
10+
background-color: #f0f0f0;
11+
border: 1px solid black;
12+
13+
}
14+
15+
h1{
16+
color: blue
17+
18+
19+
}
20+

ToDoApp/html/todo.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>ToDo App</title>
7+
<link rel="stylesheet" href="/css/todo.css">
8+
</head>
9+
<body>
10+
<div class="container">
11+
<h1>ToDo List</h1>
12+
<form id="todo-form">
13+
<input type="text" id="todo-input" placeholder="Add a new task..." required >
14+
<button type="submit" onclick="AddTask()">Add</button>
15+
</form>
16+
<ul id="todo-list"></ul>
17+
</div>
18+
19+
<script src="/js/todo.js"></script>
20+
21+
</body>
22+
</html>

ToDoApp/js/todo.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
const inputbox= document.getElementById("todo-input");
3+
4+
const list = document.getElementById("todo-list");
5+
6+
function AddTask() {
7+
8+
if (inputbox.value === "") {
9+
alert("Please enter a task.");
10+
return;
11+
} else {
12+
const li = document.createElement("li");
13+
li.innerHTML = inputbox.value + " <button class='delete' onclick='DeleteTask(this)'>Delete</button>";
14+
list.appendChild(li);
15+
16+
}
17+
inputbox.value = ""; // Clear the input box after adding the task
18+
19+
20+
21+
}
22+
23+
24+
function DeleteTask(button) {
25+
button.parentElement.remove(); // This removes the <li> element
26+
}

0 commit comments

Comments
 (0)