-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
89 lines (70 loc) · 2.24 KB
/
app.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
let lightMode = document.getElementById("icon");
let bckImage = document.getElementById("bg-image");
lightMode.addEventListener("click", function () {
if (document.body.style.backgroundColor === "black") {
document.body.style.backgroundColor = "white";
lightMode.innerHTML = `<i class="fas fa-moon"></i>`
bckImage.innerHTML = `<img src="img/bg-desktop-light.jpg" alt="">`
}
else {
document.body.style.backgroundColor = "black";
lightMode.innerHTML = `<i class="fas fa-sun"></i>`
bckImage.innerHTML = `<img src="img/bg-desktop-dark.jpg" alt="">`
}
})
var myNodelist = document.getElementsByTagName("LI");
var i;
for (i = 0; i < myNodelist.length; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myNodelist[i].appendChild(span);
myNodelist[i].appendChild(span);
}
// Click on a close button to hide the current list item
var close = document.getElementsByClassName("close");
var update = 5
var count = document.getElementById("count-number")
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
update-=1;
count.innerText = update;
}
}
function toggle(){
let m = document.querySelector('ul')
var i;
for(i=0;i<=m.length; i++){
m[i].onclick = function(){
this.classList.toggle("checked")
}
}
}
function newElement() {
var li = document.createElement('li')
var input = document.getElementById('typing').value;
var t = document.createTextNode(input)
li.appendChild(t);
if (input === "") {
alert("enter a to-do item")
}
else {
document.getElementById("mylist").appendChild(li);
}
document.getElementById('typing').value = ""
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
li.appendChild(span)
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
}