-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprob7.html
39 lines (27 loc) · 999 Bytes
/
prob7.html
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
<!-- // The Local Storage Manager: You are working on a note-taking app, and you want to implement a function named saveNoteToLocalStorage that takes a note object and saves it to the browser's local storage. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button>Add Note</button>
<div class="note"></div>
<script>
function saveNoteToLocalStorage(note) {
localStorage.setItem("note", note);
}
let note = localStorage.getItem("note")
if(note){
document.querySelector(".note").innerHTML = note
}
document.querySelector("button").addEventListener("click", () => {
let note = prompt("Enter your note")
saveNoteToLocalStorage(note)
document.querySelector(".note").innerHTML = note
})
</script>
</body>
</html>