-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacessandoAtributos2.html
32 lines (29 loc) · 1.01 KB
/
acessandoAtributos2.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Acessando Atributos #02</title>
<link rel='stylesheet' href='css/estilo.css'>
</head>
<body class='conteudo exercicio'>
<div>
<label for="compras">Compras</label>
<ul id="compras" destino='escritório' data-urgencia="5">
<li>Café</li>
<li>Água</li>
<li>Copo Descartável</li>
</ul>
</div>
<script>
const lista = document.querySelector('div ul[destino="escritório"]') // ou ainda poderia const lista = document.querySelector(#compras)
console.log('Elemento "ul".............')
console.log('childNodes', lista.childNodes)
console.log('destino', lista.destino)
console.log('getAttribute', lista.getAttribute('destino'))
console.log('hasAttribute', lista.hasAttribute('destino'))
lista.setAttribute('destino', 'empresa')
lista.setAttribute('status','aberto')
lista.removeAttribute('destino')
</script>
</body>
</html>