-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaulajs11.html
More file actions
45 lines (34 loc) · 1.32 KB
/
Copy pathaulajs11.html
File metadata and controls
45 lines (34 loc) · 1.32 KB
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
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Aula 11</title>
<script>
var contador = 100; //Variável global
function novoItem() {
var li = document.createElement("li");
li.innerHTML = "Item " + contador;
if(contador % 2 == 0) {
var lista = document.getElementById("listaPares");
} else {
var lista = document.getElementById("listaImpares");
}
lista.appendChild(li);
contador++;
}
function limpaItens() {
document.getElementById("listaPares").innerHTML = '';
document.getElementById("listaImpares").innerHTML = '';
}
</script>
</head>
<body>
<h1>JavaScript Aula 11</h1>
<h2>if</h2>
<button onclick="novoItem();">Novo Item</button>
<button onclick="limpaItens();">Limpa Itens</button>
<ol id="listaPares" style="width: 50%; background-color: aqua">
</ol>
<ol id="listaImpares" style="width: 50%; background-color: aqua">
</ol>
</body>
</html>