-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
30 lines (26 loc) · 985 Bytes
/
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
function addIndex() {
let input = document.getElementById('input');
let elenco = document.getElementById('elenco');
let count = document.getElementById('count');
if (input.value.trim() !== '') {
let list = document.createElement('li');
list.appendChild(document.createTextNode(input.value));
let bottone = document.createElement('button');
bottone.appendChild(document.createTextNode('Remove'));
bottone.onclick = function() {
removeList(list);
};
list.appendChild(bottone);
elenco.appendChild(list);
input.value = '';
let varCount = parseInt(count.innerText, 10);
count.innerText = varCount + 1;
}
}
function removeList(task){
let elenco = document.getElementById('elenco');
elenco.removeChild(task);
let count = document.getElementById('count');
let varCount = parseInt(count.innerText, 10);
count.innerText = varCount - 1;
}