-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (38 loc) · 1.41 KB
/
Copy pathscript.js
File metadata and controls
57 lines (38 loc) · 1.41 KB
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
46
47
48
49
50
51
52
53
const form = document.getElementById('formTarefa')
const nomeTarefa = document.getElementById('nomeTarefa')
const descricaoTarefa = document.getElementById('descricaoTarefa')
const listaTarefas = document.getElementById('listaTarefas')
form.addEventListener("submit", (e)=> {
e.preventDefault();
const tarefa = nomeTarefa.value.trim();
const descricao = descricaoTarefa.value.trim();
if (!tarefa || !descricao) {
alert("Por favor, preencha todos os dados!")
return;
}
console.log(tarefa);
const item = document.createElement('li')
const paragrafo = document.createElement('p')
paragrafo.textContent = `${tarefa}`
const botaoConfirmar = document.createElement('button')
botaoConfirmar.classList.add('confirmar')
botaoConfirmar.textContent = 'Confirmar'
listaTarefas.appendChild(item)
item.appendChild(paragrafo)
item.appendChild(botaoConfirmar)
console.log(botaoConfirmar);
const botaoRemover = document.createElement('button')
botaoRemover.classList.add('remover')
botaoRemover.textContent = 'Remover'
item.appendChild(botaoRemover)
if (botaoConfirmar) {
botaoConfirmar.addEventListener('click', () => {
item.classList.add('completed')
})
}
if (botaoRemover) {
botaoRemover.addEventListener( 'click', () => {
item.remove('li')
})
}
})