-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.js
48 lines (39 loc) · 1.23 KB
/
Script.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var Members = document.getElementById("Members");
var Add = document.getElementById("Add");
// var Delete = document.getElementsByClassName("comot");
var ul = document.querySelector("ul");
function inputLength() {
return Members.value.length;
}
function createNewList() {
var li = document.createElement("li");
li.appendChild(document.createTextNode(Members.value));
li.addEventListener("click", function toggleDone() {
li.classList.toggle("Done");
});
ul.appendChild(li);
Members.value = "";
var remove = document.createElement("button");
remove.appendChild(document.createTextNode("delete member"));
li.appendChild(remove);
remove.classList.add("Box");
remove.addEventListener("click", function () {
li.remove();
});
}
Add.addEventListener("click", function () {
if (inputLength() > 0) {
createNewList();
} else {
alert("You gotta write something");
}
});
Members.addEventListener("keypress", function () {
if (inputLength() > 0 && event.keyCode === 13) {
createNewList();
}
});
document.querySelector("h1").classList.add("Heading");
document.querySelector("h2").classList.add("Sub");
Members.classList.add("Box");
Add.classList.add("Box");