feat: add click counter button interaction
This commit is contained in:
12
clase-9.js
12
clase-9.js
@@ -1 +1,13 @@
|
|||||||
// Agregar acá el código javascript para los ejercicios
|
// Agregar acá el código javascript para los ejercicios
|
||||||
|
|
||||||
|
// Ejercicio 1
|
||||||
|
|
||||||
|
const clickCounter = document.getElementById('clickCounter');
|
||||||
|
const clickButton = document.getElementById('clickButton');
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
clickButton.addEventListener('click', () => {
|
||||||
|
count++;
|
||||||
|
clickCounter.textContent = count;
|
||||||
|
});
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Clase 9 - Eventos</h1>
|
<h1>Clase 9 - Eventos</h1>
|
||||||
<div id="ejercicio-1">
|
<div id="ejercicio-1">
|
||||||
<!-- Agregar acá el código HTML que haga falta para el ejercicio 1 -->
|
<p> Este boton ha sido clickeado <span id="clickCounter">0</span> veces</p>
|
||||||
|
<button id="clickButton">Clickeame!</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="ejercicio-2">
|
<div id="ejercicio-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user