-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
41 lines (25 loc) · 921 Bytes
/
script.js
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
let new_task = document.getElementById("new-task");
let tasks = document.getElementById("tasks");
// --------------------------------------------------------------------------------------------------
function add_task() {
if (new_task.value === "") {
alert("Please Add A Task!");
}
else {
let task = document.createElement("p");
task.id = "task";
let span = document.createElement("span");
span.innerText = new_task.value;
span.id = "span";
let delete_btn = document.createElement("button");
delete_btn.innerText = "Delete";
delete_btn.id = "delete";
tasks.appendChild(task);
task.appendChild(span);
task.appendChild(delete_btn);
new_task.value = "";
delete_btn.addEventListener("click", () => {
task.remove();
})
}
}