-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
44 lines (32 loc) · 841 Bytes
/
Copy pathindex.html
File metadata and controls
44 lines (32 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<title>To-Do App</title>
</head>
<body>
<h1>To-Do App</h1>
<input type="text" id="taskInput" placeholder="Enter task">
<button onclick="addTask()">Add</button>
<ul id="taskList"></ul>
<script>
function addTask() {
let input = document.getElementById("taskInput");
let task = input.value;
if(task === "") return;
let li = document.createElement("li");
li.innerText = task;
li.onclick = function() {
li.style.textDecoration = "line-through";
}
let delBtn = document.createElement("button");
delBtn.innerText = "X";
delBtn.onclick = function() {
li.remove();
}
li.appendChild(delBtn);
document.getElementById("taskList").appendChild(li);
input.value = "";
}
</script>
</body>
</html>