forked from simranlotey/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodojs.js
28 lines (26 loc) · 810 Bytes
/
todojs.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
let input=document.querySelector("input");
let btn=document.querySelector("button");
let ull=document.querySelector("ul");
btn.addEventListener("click", function (){
let i=document.createElement("li");
i.innerText=input.value;
let del=document.createElement("button");
del.innerText="delete";
del.classList.add("delete");
i.appendChild(del);
ull.appendChild(i);
input.value=" ";
})
//let dell=document.querySelectorAll(".delete");
// for(btns of dell){
// btns.addEventListener("click",function(){
// let par=this.parentElement;
// par.remove();
// })
// }
ull.addEventListener("click",function(event){
if(event.target.nodeName=="BUTTON"){
let ff=event.target.parentElement;
ff.remove();
}
})