-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodolist.js
More file actions
30 lines (24 loc) · 1.06 KB
/
todolist.js
File metadata and controls
30 lines (24 loc) · 1.06 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
// Let's create a simple todo application
// Show an unordered list of todo's
// Show an input to enter a new todo
// Show a button to add a todo. When the button is clicked:
// The text from the input box is used to add a list item to the bottom of the list
// The text from the input box is cleared out.
// When the user clicks on a list item, it is removed
// Extra Credit: - When a list item is clicked, cross it out, then remove it after 1 second.
function newTask(){
var list = document.querySelector('ul');
var newLI = document.createElement('li');
newLI.innerHTML = document.querySelector("#task").value;
// newLI.innerHTML = listItem;
list.appendChild(newLI); //Appends to bottom of list
document.querySelector("#task").value = " "; //clears input field after click
//14 and 17 have duplication "document.querySelector("#task").value
};
document.querySelector('ul').addEventListener('click', function(event){
var noMore = event.target
noMore.style["text-decoration"] = 'line-through';
setTimeout(function(){
noMore.remove();
}, 1000);
});