-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (35 loc) · 1.01 KB
/
script.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
const input = document.querySelector('.input input');
const taskList = document.querySelector('.task_list');
const first = document.querySelector('.first');
// let lis = []
input.onkeyup = e => {
// (first!==null || first!==undefined)? taskList.removeChild(first):null;
if(e.key === "Enter"){
const li = document.createElement('li');
li.setAttribute('class', '_list');
li.innerText = input.value;
taskList.appendChild(li);
input.value = "";
// lis = [...lis, li];
}
taskList.removeChild(first);
}
// setInterval(()=> {
// for(let li of lis){
// li.onclick = e => {
// if(e.isTrusted){
// li.classList.add('fade-out');
// li.style.textDecoration = 'none';
// li.innerText = "Removed";
// setTimeout(()=>taskList.removeChild(li), 700);
// }
// }
// }
// },500)
taskList.onclick = e => {
if(e.isTrusted){
e.target.classList.add('fade-out');
e.target.innerText = "Removed";
setTimeout(()=>taskList.removeChild(e.target), 800);
}
}