-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes1.js
34 lines (31 loc) · 1.29 KB
/
notes1.js
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
let addToDoButton = document.getElementById("addToDo");
let toDocontainer = document.getElementById("toDoContainer")
let inputField = document.getElementById("inputField");
let historyC = document.getElementById("history");
addToDoButton.addEventListener("click", function () {
var paragraph = document.createElement("p");
var deleteItem = document.createElement("p");
var hist = document.createElement("p");
paragraph.classList.add("paragraph-styling")
paragraph.innerText = inputField.value;
toDocontainer.appendChild(paragraph);
deleteItem.innerHTML = "<button>Delete</button>";
if (inputField.value !== "") {
toDocontainer.appendChild(deleteItem);
}
deleteItem.classList.add("btn");
inputField.value = "";
paragraph.addEventListener("click", function () {
paragraph.style.textDecoration = "line-through";
})
paragraph.addEventListener("dblclick", function () {
toDocontainer.removeChild(paragraph);
})
deleteItem.addEventListener("click", function () {
toDocontainer.removeChild(paragraph);
toDocontainer.removeChild(deleteItem);
historyC.appendChild(paragraph);
historyC.appendChild(hist);
hist.innerHTML = "<button>Delete Permanently</button>";
})
})