-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (36 loc) · 1.06 KB
/
index.js
File metadata and controls
54 lines (36 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
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
/*
TODO
-user should be able to view all tasks
-able to add a to-do item to the list
-should be able to mark a task complete
-remove tasks by clicking
-page shouldn't be ugly
*/
let userInput = document.querySelector('#userText')
let userSubButton = document.querySelector('#userSubBtn')
let taskList = document.querySelector('#taskList')
let taskCounter = 1
let tasks = []
function grabUserInput(){
tasks.push(userInput.value)
// clear out input box after a submit
createTaskDiv(userInput.value)
}
function clickTask(id){
let task = document.querySelector(`#${id}`)
taskList.removeChild(task)
}
function clickTask(id){
let task = document.querySelector(`#${id}`)
task.className = "complete"
}
function createTaskDiv(inVal){
let curId = `task${taskCounter}`
let newDiv = document.createElement('div')
newDiv.id = curId
let newTask = taskList.appendChild(newDiv)
newTask.append(inVal)
newTask.addEventListener('click', () => clickTask(curId))
taskCounter++
}
userSubButton.addEventListener("click", () => grabUserInput())