-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
35 lines (28 loc) · 864 Bytes
/
index.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
<!DOCTYPE html>
<html lang="es">
<head>
<title>Ejemplo eventos</title>
<meta charset="UTF-8" />
</head>
<body>
<button id="miBoton">Añade item</button>
<ul id="miLista">
</ul>
<script>
window.addEventListener('DOMContentLoaded', function() {
let contador = 1;
const boton = document.getElementById('miBoton')
const lista = document.getElementById('miLista')
boton.addEventListener('click', function() {
const nuevoLi = document.createElement('li');
const contenido = document.createTextNode(`Item ${contador}`);
nuevoLi.append(contenido)
setTimeout(function() {
lista.append(nuevoLi)
}, 1500)
contador += 1;
})
})
</script>
</body>
</html>