-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (32 loc) · 1.16 KB
/
Copy pathscript.js
File metadata and controls
33 lines (32 loc) · 1.16 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
const input=document.querySelector('input');
const btn=document.querySelector('.addTask > button');
btn.addEventListener('click',addList);
input.addEventListener('keyup',(e)=>{
(e.keyCode== 13 ? addList(e):null);
});
function addList(e){
const notCompleted=document.querySelector('.notCompleted');
const Completed=document.querySelector('.Completed');
const newLi=document.createElement('li');
const checkBtn=document.createElement('button');
const delBtn=document.createElement('button');
checkBtn.innerHTML='<i class="fa fa-check"></i>';
delBtn.innerHTML='<i class="fa fa-trash"></i>';
if(input.value!==''){
newLi.textContent=input.value;
input.value='';
notCompleted.appendChild(newLi);
newLi.appendChild(checkBtn);
newLi.appendChild(delBtn);
}
checkBtn.addEventListener('click',function(){
const parent=this.parentNode;
parent.remove();
Completed.appendChild(parent);
checkBtn.style.display='none';
});
delBtn.addEventListener('click',function(){
const parent=this.parentNode;
parent.remove();
});
}