From 180cfa585c93a70e1d5ceb1e7c84fcc201a06b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Blas=20Alarc=C3=B3n?= <47840816@terciariourquiza.edu.ar> Date: Thu, 21 May 2026 19:22:04 -0300 Subject: [PATCH] Agregue un campo de texto a la pagina y abajo un parrafo que cuenta cuantos caracteres hay ingresados en el campo --- clase-9.js | 16 ++++++++++++---- index.html | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/clase-9.js b/clase-9.js index ec87ff6..50640d9 100644 --- a/clase-9.js +++ b/clase-9.js @@ -1,10 +1,18 @@ // Agregar acá el código javascript para los ejercicios -const boton = document.querySelector("button"); -const parrafo = document.querySelector("p"); +const boton1 = document.querySelector("button"); +const parrafo1 = document.querySelector("p"); var i = 0 -boton.addEventListener("click", function () { +boton1.addEventListener("click", function () { i = i + 1 - parrafo.textContent = `Este boton ha sido clickeado ${i} veces`; + parrafo1.textContent = `Este boton ha sido clickeado ${i} veces`; console.log(`El botón fue clickeado ${i} veces`); +}); + +const campo = document.querySelector("input"); +const parrafo2 = document.querySelector("#contadorCaracteres"); + +campo.addEventListener("input", (e) => { + parrafo2.textContent = `El campo de texto tiene ${e.target.value.length} caracteres`; + console.log(e.target.value); }); \ No newline at end of file diff --git a/index.html b/index.html index f27efa8..43bee2d 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,8 @@
El campo de texto tiene 0 caracteres.