-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
64 lines (43 loc) · 1.43 KB
/
App.js
File metadata and controls
64 lines (43 loc) · 1.43 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//yakalama fonks.
document.querySelector("form").addEventListener("submit", submitForm);
document.querySelector("ul").addEventListener("click",silVeyaYapıldı)
document.getElementById("clearAll").addEventListener("click", hepsiniSil);
function submitForm(e){
let input = document.querySelector("input");
if (input.value != "")
listeyeEkle(input.value);
input.value = "";
}
function silVeyaYapıldı(e){
if(e.target.name == "butonYapıldı")
yapıldı(e);
if(e.target.name == "butonSil")
sil(e);
}
function hepsiniSil(e){
document.querySelector("ul").innerHTML = "";
}
function listeyeEkle (event){
let ul = document.querySelector("ul");
let li = document.createElement("li");
li.innerHTML = `
<span class = "todo-item">${event}</span>
<button name = "butonYapıldı"><i class="fa-solid fa-circle-check"></i></button>
<button name = "butonSil"><i class="fa-solid fa-trash"></i></button>
`;
li.classList.add("todo-list-item");
ul.appendChild(li);
}
function yapıldı(e){
let item = e.target.parentNode;
if(item.style.textDecoration == "line-through")
item.style.textDecoration = "none"
else
item.style.textDecoration = "line-through"
}
function sil(e){
let item = e.target.parentNode;
item.addEventListener("transitionend", function(){
})
item.classList.add("todo-list-item-fall");
}