-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 949 Bytes
/
index.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
const addButton = document.querySelector(".add-button");
const inputButton = document.querySelector(".input-button");
const input = document.querySelector(".input");
const list = document.querySelector('.list');
let counter = 0;
addButton.addEventListener('click', () => {
const listElement = document.createElement("li");
listElement.className = "list-item";
listElement.id = "list-Item";
listElement.innerText = `I am the ${++counter} item on the list`;
list.appendChild(listElement);
});
inputButton.addEventListener('click', (e) => {
e.preventDefault();
const myIdea = input.value;
const newElement = document.createElement("li");
newElement.className = "list-item";
newElement.id = "list-item";
newElement.innerText = myIdea;
list.appendChild(newElement);
input.value = "";
if (myIdea == "") {
alert('Your list will look better when you put here something 🤓')
}
});