forked from junginny/todo-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
29 lines (25 loc) · 928 Bytes
/
Copy pathmain.js
File metadata and controls
29 lines (25 loc) · 928 Bytes
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
function addNewList() {
alert('hello world alert!');
console.log('hello world console');
}
function addListItem() {
console.log("hello world!")
let list = document.getElementById("grocery-list");
let itemInput = document.getElementById("new-list-item");
let newItem = document.createElement("li");
newItem.appendChild(document.createTextNode(itemInput.value));
list.appendChild(newItem);
}
function deleteListItem(item) {
// remove li element (item) from ol element (item.parentNode)
item.parentNode.removeChild(item);
}
function completeListItem(item) {
if (item.checked) { // true if the input checkbox is checked
item.parentNode.style.textDecoration = "line-through";
// in css, this would be: "text-decoration: line-through"
} else {
item.parentNode.style.textDecoration = "none";
// in css, this would be: "text-decoration: none"
}
}