-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (29 loc) · 932 Bytes
/
Copy pathscript.js
File metadata and controls
40 lines (29 loc) · 932 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
let count = 0;
function addNote() {
const noteinput = document.querySelector('.note-input');
const notetext = noteinput.value.trim();
if (notetext === "") {
alert("please enter something here");
return;
}
count++;
const notesContainer = document.querySelector('.notes-container');
const noteElement = document.createElement('div');
noteElement.classList.add('note');
const title = document.createElement("h2");
title.textContent = "Note" + count;
const para = document.createElement("p");
para.textContent = notetext;
;
const deleteBtn = document.createElement("button");
deleteBtn.textContent = "Delete";
deleteBtn.classList.add("delete-btn");
deleteBtn.addEventListener("click", function() {
noteElement.remove();
});
noteElement.appendChild(title);
noteElement.appendChild(para);
noteElement.appendChild(deleteBtn);
notesContainer.appendChild(noteElement);
noteinput.value = "";
}