-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (37 loc) · 1 KB
/
script.js
File metadata and controls
41 lines (37 loc) · 1 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
const inputBox = document.getElementById("inputbox");
const list_container = document.getElementById("List");
function Addtask()
{
if (inputBox.value === ''){
alert("You have to write something!");
}
else{
let li = document.createElement("li");
li.innerHTML = inputBox.value;
list_container.appendChild(li);
let span = document.createElement("Span");
span.innerHTML = "\u00d7";
li.appendChild(span);
}
inputBox.value = "";
datasave();
}
list_container.addEventListener("click", function(f)
{
if(f.target.tagName === "LI"){
f.target.classList.toggle("checked");
datasave();
}else if(f.target.tagName === "SPAN"){
f.target.parentElement.remove();
datasave();
}
}, false);
function datasave()
{
localStorage.setItem("da_ta", list_container.innerHTML);
}
function show_list()
{
list_container.innerHTML = localStorage.getItem("da_ta");
}
show_list();