Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit afbbe73

Browse files
committed
removed .classList from js file
1 parent 2fef305 commit afbbe73

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

week-3/todo-list/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</head>
1111
<body>
1212
<form>
13+
1314
<div class="todo-style">
1415
<label for="todo-list" id="add-style">Add new Todos</label>
1516
<div class="line"></div>
@@ -20,10 +21,7 @@
2021
<button type="button" onclick="addNewTodo()">Add Todo</button>
2122
<button type="submit" >Remove all completed </button>
2223
</div>
23-
24-
<ul id="task-list">
25-
26-
</ul>
24+
<ul id="task-list"></ul>
2725

2826

2927
</form>

week-3/todo-list/script.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
// These are the same todos that currently display in the HTML
2-
// You will want to remove the ones in the current HTML after you have created them using JavaScript
31
let todos = [
42
{ task: "Wash the dishes", completed: false },
53
{ task: "Do the shopping", completed: false },
64
];
75

8-
// This function will take the value of the input field and add it as a new todo to the bottom of the todo list. These new todos will need the completed and delete buttons adding like normal.
96
function addNewTodo(event) {
107

118
let list = document.getElementById("todo-list");
@@ -14,11 +11,11 @@ function addNewTodo(event) {
1411

1512
let li = document.createElement("li")
1613
li.classList.add("style-list");
17-
list.appendChild(li);
18-
14+
list.appendChild(li);
15+
16+
1917
let container = document.createElement("span")
20-
container.className = "badge bg-primary rounded-pill";
21-
container.classList.add("layout");
18+
container.classList.add("layout");
2219
list.appendChild(container);
2320

2421

@@ -28,6 +25,7 @@ function addNewTodo(event) {
2825
checkIcon.onclick = function() {
2926
li.classList.toggle("completed");
3027
}
28+
container.appendChild(checkIcon);
3129

3230

3331
let trashIcon = document.createElement("i");
@@ -36,7 +34,6 @@ function addNewTodo(event) {
3634
trashIcon.onclick = function(){
3735
li.remove();
3836
};
39-
container.appendChild(checkIcon);
4037
container.appendChild(trashIcon);
4138

4239
let textNode = document.createTextNode(listValue);
@@ -51,11 +48,10 @@ function addNewTodo(event) {
5148
}
5249

5350

54-
// Advanced challenge: Write a fucntion that checks the todos in the todo list and deletes the completed ones (we can check which ones are completed by seeing if they have the line-through styling applied or not).
5551
function deleteAllCompletedTodos(event) {
5652
let todoList = document.getElementById("task-list");
57-
let completedItems = document.querySelectorAll(".completed");
58-
completedItems.forEach(function (item) {
53+
let itemsTocompleted = document.querySelectorAll(".completed");
54+
itemsTocompleted.forEach(function (item) {
5955
todoList.removeChild(item);
6056
});
6157
}

week-3/todo-list/style.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ body{
33
background-repeat: no-repeat;
44
background-attachment: fixed;
55
background-position: center;
6-
background-size: auto 100%;
6+
background-size: auto;
77
background-image: url("./assets/world.jpg");
88
}
9-
/* form{
10-
margin-left: 600px;
11-
12-
} */
9+
1310
.completed{
1411
text-decoration: line-through;
1512
color: rgb(24, 27, 24);
@@ -79,6 +76,9 @@ button{
7976
}
8077

8178
@media screen and (max-width: 768px) {
79+
.layout{
80+
padding-left:200px;
81+
}
8282
form{
8383
align-items: flex-start;
8484
justify-content: start;

0 commit comments

Comments
 (0)