-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotess.html
More file actions
85 lines (69 loc) · 2.31 KB
/
Copy pathnotess.html
File metadata and controls
85 lines (69 loc) · 2.31 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Homework Notes</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 100px;
margin-bottom: 10px;
}
button {
padding: 10px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Homework Notes</h1>
<textarea id="noteInput" placeholder="Type your homework notes here..."></textarea>
<button onclick="saveNote()">Save Note</button>
<button onclick="clearNotes()">Clear Notes</button>
<h2>Notes:</h2>
<ul id="noteList"></ul>
<script>
// Function to save a note
function saveNote() {
var noteInput = document.getElementById('noteInput');
var noteList = document.getElementById('noteList');
// Get existing notes from localStorage or initialize an empty array
var notes = JSON.parse(localStorage.getItem('homeworkNotes')) || [];
// Add the new note to the array
notes.push(noteInput.value);
// Save the updated array back to localStorage
localStorage.setItem('homeworkNotes', JSON.stringify(notes));
// Clear the input field
noteInput.value = '';
// Refresh the displayed notes
displayNotes();
}
// Function to display notes
function displayNotes() {
var noteList = document.getElementById('noteList');
// Clear existing notes
noteList.innerHTML = '';
// Get notes from localStorage
var notes = JSON.parse(localStorage.getItem('homeworkNotes')) || [];
// Display each note in the list
notes.forEach(function(note) {
var li = document.createElement('li');
li.textContent = note;
noteList.appendChild(li);
});
}
// Function to clear all notes
function clearNotes() {
localStorage.removeItem('homeworkNotes');
displayNotes();
}
// Initial display of notes when the page loads
displayNotes();
</script>
</body>
</html>