-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (29 loc) · 1.14 KB
/
script.js
File metadata and controls
36 lines (29 loc) · 1.14 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
function addTask(period) {
const input = document.getElementById(`new-${period}-task`);
const taskList = document.getElementById(`${period}-tasks`);
const taskText = input.value.trim();
if (taskText) {
const newTask = document.createElement('li');
newTask.textContent = taskText;
newTask.addEventListener('click', () => {
const confirmDeletion = confirm('Você realmente deseja excluir esta tarefa?');
if (confirmDeletion) {
taskList.removeChild(newTask);
taskList.removeChild(button);
}
});
newTask.addEventListener('dblclick', () => {
newTask.classList.toggle('completed');
});
taskList.appendChild(newTask);
const button = document.createElement('button');
button.classList.add("lixeira");
button.textContent = "Remover";
newTask.appendChild(button);
button.addEventListener('click', () => {
taskList.removeChild(newTask);
taskList.removeChild(button);
})
input.value = '';
}
}