-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (32 loc) · 987 Bytes
/
app.js
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
const push = document.querySelector('#push');
const input = document.querySelector('#newtask input');
const tasks = document.querySelector('#tasks');
push.onclick = function (){
if(input.value.length == 0){
alert('Please enter the new task')
}else{
tasks.innerHTML += `
<div class="task">
<span id="taskname">
${input.value};
</span>
<button class = "delete">
<i class="fa-sharp fa-solid fa-delete-left"></i>
</button>
</div>
`
const currentTask = document.querySelectorAll('.delete');
for(let i = 0; i<currentTask.length; i++){
currentTask[i].onclick = function(){
this.parentNode.remove();
}
}
}
var task = document.querySelectorAll(".task");
for(var i = 0; i<task.length; i++){
task[i].onclick = function (){
this.classList.toggle('completed');
}
input.value = "";
}
}