-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (28 loc) · 729 Bytes
/
app.js
File metadata and controls
30 lines (28 loc) · 729 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
const item = document.querySelector("#item")
const toDoBox = document.querySelector("#to-do-box")
item.addEventListener(
"keyup",
function(event) {
if (event.key == "Enter") {
addToDo(this.value)
this.value = ""
}
}
)
const addToDo = (item) => {
const listItem = document.createElement("li");
listItem.innerHTML = ` ${item} <span class="fw-bolder text-white">X </span>`;
listItem.addEventListener(
"click",
function() {
this.classList.toggle("done");
}
)
listItem.querySelector("i").addEventListener(
"click",
function(){
listItem.remove()
}
)
toDoBox.appendChild(listItem)
}