-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAula-09.js
More file actions
25 lines (19 loc) · 728 Bytes
/
Aula-09.js
File metadata and controls
25 lines (19 loc) · 728 Bytes
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
// Criar um elemento <li> e o nó de texto
// Criar o nó do texto
//var elemento = document.createElement('li');
//var texto = document.createTextNode('item da lista adicionado');
//elemento.appendChild(texto);
// Recuperando o elemento lista e
//anexando o elemeno <li> ao final da lista
//var lista = document.getElementsByTagName('ul')[0];
//lista.appendChild(elemento);
//inserBefore
var lista = document.getElementsByTagName('ul')[0];
var itens = lista.getElementsByTagName('li');
//criando o elemento
var elemento = document.createElement('li');
elemento.textContent = 'outro item';
// inserindo valor em posição específica
//lista.insertBefore(elemento, itens[1]);
// removechild
lista.removeChild(itens[3]);