-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
40 lines (35 loc) · 1.18 KB
/
main.js
File metadata and controls
40 lines (35 loc) · 1.18 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
//const okBtn = document.querySelector(".myButton");
const myForm = document.querySelector(".myForm");
//okBtn.addEventListener("click", function ()
myForm.addEventListener("submit", function(event){
event.preventDefault();
console.log("click!");
const myInput = document.querySelector(".myInput");
const funToDo = myInput.value.trim();
const noInput = document.querySelector(".noInput");
const myList = document.querySelector(".myList");
if (funToDo.length == 0) {
console.log("no text");
noInput.classList.add("error");
return;
} else {
noInput.classList.remove("error");
}
console.log("text added");
const funList = document.createElement("li");
funList.classList.add("funList");
const funItem = document.createElement("span");
funItem.classList.add("funItem");
funItem.innerText = funToDo;
funList.append(funItem);
const delBtn = document.createElement("button");
delBtn.classList.add("delBtn");
delBtn.innerText = "delet";
funList.append(delBtn);
myList.append(funList);
delBtn.addEventListener("click", function () {
funList.remove();
});
myInput.value = "";
}
);