-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.js
37 lines (33 loc) · 973 Bytes
/
todo.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
window.onload=()=>{
const btn= document.querySelector('#btn1');
const ul = document.getElementById('list1');
const f = document.frm;
const s=f.ser;
btn.addEventListener('click',()=>{
let item = prompt("Enter ToDo?");
ul.innerHTML+='<li>'+item.toUpperCase()+'</li>';
});
ul.addEventListener('dblclick',(e)=>{
let li=ul.querySelectorAll('li');
ul.innerHTML="";
for(let x of li){
if(e.target.innerText!=x.innerText){
ul.innerHTML+='<li>'+x.innerHTML+'</li>';
}
}
});
let find=(val)=>{
let item = ul.querySelectorAll('li');
item.forEach(x=>{
if(!x.innerText.toUpperCase().includes(val.toUpperCase())){
x.classList.add('hide');
}
else{
x.classList.remove('hide');
}
});
}
s.addEventListener('keyup',(e)=>{
find(s.value);
});
}