-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (89 loc) · 2.82 KB
/
index.html
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lista de Tarefas</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
h1 {
color: #333;
}
#taskInput {
padding: 10px;
width: 300px;
border: 1px solid #ccc;
border-radius: 4px;
}
#addTaskButton {
padding: 10px 20px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#addTaskButton:hover {
background-color: #218838;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background-color: #fff;
margin: 5px 0;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
display: flex;
justify-content: space-between;
}
.removeTaskButton {
background-color: #dc3545;
color: white;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
}
.removeTaskButton:hover {
background-color: #c82333;
}
</style>
</head>
<body>
<h1>Lista de Tarefas</h1>
<input type="text" id="taskInput" placeholder="Digite sua tarefa...">
<button id="addTaskButton">Adicionar Tarefa</button>
<ul id="taskList"></ul>
<script>
// Seleciona o input, o botão e a lista
const taskInput = document.getElementById('taskInput');
const addTaskButton = document.getElementById('addTaskButton');
const taskList = document.getElementById('taskList');
// Adiciona uma tarefa
addTaskButton.addEventListener('click', function() {
const taskText = taskInput.value;
if (taskText.trim() !== "") {
const li = document.createElement('li');
li.innerHTML = taskText + ' <button class="removeTaskButton">Remover</button>';
taskList.appendChild(li);
// Limpa o campo de texto após adicionar a tarefa
taskInput.value = '';
// Função para remover a tarefa
li.querySelector('.removeTaskButton').addEventListener('click', function() {
taskList.removeChild(li);
});
} else {
alert("Por favor, digite uma tarefa.");
}
});
</script>
</body>
</html>