-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (20 loc) · 806 Bytes
/
script.js
File metadata and controls
25 lines (20 loc) · 806 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
const notesContainer = document.querySelector(".notes-container");
const notesBtn = document.querySelector(".btn");
notesBtn.addEventListener("click", () => {
let inputBox = document.createElement("p");
let img = document.createElement("img");
inputBox.className = "input-box";
inputBox.setAttribute("contenteditable", "true");
img.src = "images/delete.png";
img.className = "delete-icon";
img.alt = "Delete";
img.style.width = "16px"; // Optional: to keep delete icon small
img.style.cursor = "pointer"; // Optional: change cursor to pointer
inputBox.appendChild(img);
notesContainer.appendChild(inputBox);
});
notesContainer.addEventListener("click", function (e) {
if (e.target.tagName === "IMG") {
e.target.parentElement.remove();
}
});