-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 921 Bytes
/
index.js
File metadata and controls
36 lines (30 loc) · 921 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
29
30
31
32
33
34
35
36
var completetaskholder=document.getElementById('completed-tasks');
function newtask(){
var inputValue = document.getElementById("task").value;
var li = document.createElement("li");
var t = document.createTextNode(inputValue);
li.appendChild(t);
if (inputValue === '') {
alert("You must write something!");
return;
} else {
console.log(inputValue);
}
document.getElementById("task").value = "";
var checkBox=document.createElement("input")
checkBox.type="checkbox";
checkBox.classList='checked';
checkBox.onclick= completeItem;
li.appendChild(checkBox);
var prtask=document.getElementById('myUL')
prtask.append(li);
li.onclick = removeItem;
}
function removeItem(e) {
e.target.remove();
}
function completeItem(e){
var listItem=this.parentNode;
completetaskholder.appendChild(listItem);
console.log(completetaskholder)
}