-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (30 loc) · 1.15 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const instructions = `
when click on the button,
take the value from the input,
create li element with the value,
append the li to the ul (appendChild).
reset the value of the input. `
const addTodoInput = document.querySelector('#addTodoInput');
// const addTodoButton = document.querySelector('addTodoButton');
const todoList = document.querySelector('ul');
// add event listener to button to handle clickevent
// when click on the button,
function createNewTodoListEntry() {
// take the value from the input
const inputValue = addTodoInput.value;
// take the value from the input
const newTodoItem = document.createElement('li');
// create li element with the value
newTodoItem.innerText = inputValue;
// append the li to the ul (appendChild)
todoList.appendChild(newTodoItem);
// reset the value of the input
addTodoInput.value = ' ';
}
// button.addEventListener('click', () => {
// const text = input.value;
// const li = document.createElement('li');
// li.textContent = text;
// ul.appendChild(li);
// input.value = '';
// });