forked from marquez.juan/clase-9-eventos
ejercicio 1: contador de clicks con addEventListener
This commit is contained in:
10
clase-9.js
10
clase-9.js
@@ -1 +1,9 @@
|
||||
// Agregar acá el código javascript para los ejercicios
|
||||
// Ejercicio 1 - Contador de clics
|
||||
let clickCount = 0;
|
||||
const boton = document.getElementById('miBoton');
|
||||
const parrafo = document.getElementById('contadorClicks');
|
||||
|
||||
boton.addEventListener('click', function() {
|
||||
clickCount++;
|
||||
parrafo.textContent = `Botón clickeado ${clickCount} veces`;
|
||||
});
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<body>
|
||||
<h1>Clase 9 - Eventos</h1>
|
||||
<div id="ejercicio-1">
|
||||
<!-- Agregar acá el código HTML que haga falta para el ejercicio 1 -->
|
||||
<button id="miBoton">Hacer clic</button>
|
||||
<p id="contadorClicks">Botón clickeado 0 veces</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="ejercicio-2">
|
||||
|
||||
Reference in New Issue
Block a user