-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (23 loc) · 795 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (23 loc) · 795 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
const ul = document.querySelector("ul");
const input = document.querySelector("input");
const button = document.querySelector("button");
button.addEventListener("click", ()=> {
let value = input.value;
input.value = "";
const li = document.createElement("li");
const span = document.createElement("span");
const button = document.createElement("button");
li.appendChild(span);
li.appendChild(button);
span.textContent = value;
span.setAttribute("style", "font-size: 1.8rem; font-weight: 400;")
button.textContent = "Delete";
button.style.backgroundColor = "Red";
button.style.color = "white";
ul.appendChild(li);
button.addEventListener("click", () => {
li.remove();
button.remove();
});
input.focus();
})