-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlclstrg.html
More file actions
41 lines (35 loc) · 1010 Bytes
/
lclstrg.html
File metadata and controls
41 lines (35 loc) · 1010 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Note</title>
<style>
body {
background-color: black;
color: whitesmoke;
}
.note {
padding: 40px;
}
</style>
</head>
<body>
<button>Add a note</button>
<div class="note"></div>
<script>
function saveNoteToLocalStorage(note) {
// item = JSON.stringify(note)
localStorage.setItem("note", note)
}
if (localStorage.getItem('note')) {
document.querySelector(".note").innerHTML = localStorage.getItem('note');
}
document.querySelector("button").addEventListener("click", () => {
let item = prompt("Enter the note")
saveNoteToLocalStorage(item)
document.querySelector(".note").innerHTML = localStorage.getItem('note');
})
</script>
</body>
</html>