-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.html
More file actions
38 lines (38 loc) · 1.3 KB
/
todo.html
File metadata and controls
38 lines (38 loc) · 1.3 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
<!DOCTYPE HTML>
<html>
<head>
<link rel="shortcut icon" href="icon.png" type="image/x-icon" />
<title>ToDo List</title>
<script>
function addItem() {
var newItem = document.createElement("div");
newItem.innerHTML = document.getElementById("text").value;
newItem.onclick = removeItem;
document.getElementById("list").appendChild(newItem)
saveList();
}
function removeItem() {
document.getElementById("list").removeChild(this);
saveList();
}
function saveList() {
localStorage.storedList = document.getElementById("list").innerHTML;
}
function loadList() {
document.getElementById("list").innerHTML = localStorage.storedList;
}
</script>
</head>
<body>
<a href="index.html">Home</a>
<input type="text" name="text" id="text" value="Type here to add task" />
<br>
<input type="button" name="button" id="button" value="Add" onclick="addItem();" />
<div id="list"></div>
<script>
if(localStorage.storedList) {
loadList();
}
</script>
</body>
</html>