-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsimple.html
More file actions
45 lines (42 loc) · 1.29 KB
/
simple.html
File metadata and controls
45 lines (42 loc) · 1.29 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Simple TODO List</title>
</head>
<body>
<section id="container">
<h1 class="title">TODO</h1>
<div class="input-container">
<input type="text" id="todo-input" class="todo-input" />
<input type="button" id="save-button" value="저장" />
</div>
<div class="list-container">
<ul id="todo-list" class="todo-list">
<li>밥 먹기</li>
<li>2시 약속</li>
</ul>
</div>
</section>
<script>
const inputField = document.getElementById("todo-input");
const saveButton = document.getElementById("save-button");
const todoList = document.getElementById("todo-list");
saveButton.addEventListener("click", () => {
const newTodo = inputField.value.trim();
if (newTodo === "") {
alert("내용을 입력해주세요!");
return;
}
const userConfirmed = confirm(`"${newTodo}" 저장하시겠습니까?`);
if (userConfirmed) {
const newTodoListItem = document.createElement("li");
newTodoListItem.textContent = newTodo;
todoList.appendChild(newTodoListItem);
inputField.value = "";
}
});
</script>
</body>
</html>