-
Notifications
You must be signed in to change notification settings - Fork 0
/
script002.js
51 lines (34 loc) · 1.2 KB
/
script002.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
49
50
51
/*
Preencha uma lista (<ul>) no HTML com os itens da seguinte forma:
● Diego
● Gabriel
● Lucas
*/
var nomes = [ "Diego", "Gabriel", "Lucas"];
nomes.length
console.log(nomes);
function CreateElement(){
for(var nome of nomes){
var liElement = document.createElement('li');
var liText = document.createTextNode(nome);
liElement.appendChild(liText);
var place = document.querySelector('ul')
place.appendChild(liElement)
//console.log(liElement);
}
}
function adicionar(){
var read = document.querySelector('input')
nomes.push(read.value)//Adicionar Elemento ao vetor
var liElement = document.createElement('li')
var liText = document.createTextNode(read.value)
liElement.appendChild(liText)
var place = document.querySelector('ul')
place.appendChild(liElement)
function reset(){
read.value = ''
}
reset()
console.log(nomes)
}
CreateElement()