-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.js
More file actions
25 lines (22 loc) · 833 Bytes
/
Copy pathnotes.js
File metadata and controls
25 lines (22 loc) · 833 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
document.addEventListener("DOMContentLoaded", function() {
const noteList = document.getElementById("noteList");
const noteForm = document.getElementById("noteForm");
noteForm.addEventListener("submit", function(event) {
event.preventDefault();
const noteTitle = document.getElementById("noteTitle").value;
const noteContent = document.getElementById("noteContent").value;
if (noteTitle && noteContent) {
createNoteElement(noteTitle, noteContent);
noteForm.reset();
}
});
function createNoteElement(title, content) {
const note = document.createElement("div");
note.className = "note";
note.innerHTML = `
<h2>${title}</h2>
<p>${content}</p>
`;
noteList.appendChild(note);
}
});