-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19.1bubblingProject.html
More file actions
116 lines (103 loc) · 3.32 KB
/
19.1bubblingProject.html
File metadata and controls
116 lines (103 loc) · 3.32 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.todo_main_container {
display: flex;
flex-direction: column;
gap: 20px;
align-items: center;
justify-content: flex-start;
}
.todo_btn {
padding: 8px;
background-color: rgba(128, 128, 128, 0.878);
border-radius: 4px;
cursor: pointer;
}
.todo_list {
max-width: 500px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
gap: 20px;
}
.todo_list input[type="text"] {
/* height: 60px; */
/* max-width: 400px; */
width: 100%;
padding: 10px;
}
.todo_list_main_container {
display: flex;
flex-direction: column;
gap: 20px;
max-width: 500px;
width: 100%;
}
.todo_item {
height: 60px;
width: 100%;
background-color: black;
color: white;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
gap: 20px;
padding: 10px;
border-radius: 8px;
}
</style>
</head>
<body>
<div class="todo_main_container">
<form class="todo_list">
<input type="text" name="todo_search_bar" placeholder="Add Todo">
<input type="submit" value="Add Todo" class="todo_btn">
</form>
<div class="todo_list_main_container">
<div class="todo_item">
<span>Todo Item 1</span>
<div class="todo_btn done">Done</div>
<div class="todo_btn remove">Remove</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.7.0.js" integrity="sha256-JlqSTELeR4TLqP0OG9dxM7yDPqX1ox/HfgiSLBj8+kM=" crossorigin="anonymous"></script>
<script>
$(document).ready(function () {
$(".todo_list").submit(function (e) {
e.preventDefault();
const newTodoText = $("input[type='text']", this).val();
const newTodoItem = `
<div class="todo_item">
<span>${newTodoText}</span>
<div class="todo_btn done">Done</div>
<div class="todo_btn remove">Remove</div>
</div>`;
$(".todo_list_main_container").append(newTodoItem);
$("input[type='text']", this).val("");
});
$(".todo_list_main_container").on("click", function (e) {
const clickedElement = $(e.target);
const todoItem = clickedElement.closest(".todo_item");
if (clickedElement.hasClass("remove")) {
todoItem.remove();
} else if (clickedElement.hasClass("done")) {
todoItem.find("span").css("text-decoration", "line-through");
}
});
});
</script>
</body>
</html>