-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (41 loc) · 1.06 KB
/
index.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
42
43
44
45
const data = [
// { desc: "Pagar contas" }, { desc: "Programar aquela lista de tarefas" }, { desc: "Comprar salgados" },
// { desc: "Abastecer o carro" }, { desc: "Fazer o trabalho da facul" }
];
function carregarLista() {
for (var i = 0; i < data.length; i++) {
document.querySelector("#myUL").innerHTML +=
`
<li>
${data[i].desc}
<button onclick="remover()" class="close">
<i class="fa-regular fa-trash-can"></i>
</button>
</li>
`
}
}
function adicionar() {
var inputValue = document.getElementById("myInput").value;
if (inputValue != '') {
document.querySelector("#myUL").innerHTML +=
`
<li>
${inputValue}
<button onclick="remover()" class="close">
<i class="fa-regular fa-trash-can"></i>
</button>
</li>
`
}
}
function remover() {
var close = document.getElementsByClassName("close");
for (var i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
}
carregarLista()