forked from MateusAugustoFerreira/exercicio-js-turma-tarde
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattCadastro.html
59 lines (40 loc) · 1.32 KB
/
attCadastro.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>cadastro</title>
</head>
<body>
<input id="nome" type="text" placeholder="Insira seu nome">
<input id="idade" type="number" placeholder="Insira sua idade">
<br><br>
<hr>
<br>
<p id="p"></p>
<button id="salvar" type="button">Salvar</button>
<button id="verificar" type="button">verificar</button>
</body>
</html>
<script>
let array = [];
document.getElementById("salvar").addEventListener("click", function () {
let objeto = {
nome: document.getElementById("nome").value,
idade: document.getElementById("idade").value,
};
array.push(objeto);
});
document.getElementById("verificar").addEventListener("click", function () {
for (let index = 0; index < array.length; index++) {
let element = array[index];
console.log(array[index].nome);
console.log(array[index].idade);
if (array[index].nome == 'raysson') {
document.getElementById("p").innerText = array[index].nome;
}
}
console.log(array);
});
</script>