diff --git a/clase-9.js b/clase-9.js index 217d83c..4b40054 100644 --- a/clase-9.js +++ b/clase-9.js @@ -7,3 +7,11 @@ boton.addEventListener('click', function() { clickCount++; parrafo.textContent = `Botón clickeado ${clickCount} veces`; }); + +// Ejercicio 2 - Contador de caracteres en tiempo real +const campoTexto = document.getElementById('campoTexto'); +const contadorCaracteres = document.getElementById('contadorCaracteres'); + +campoTexto.addEventListener('input', function() { + contadorCaracteres.textContent = `Caracteres ingresados: ${campoTexto.value.length}`; +}); diff --git a/index.html b/index.html index 6ba8d93..389860b 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,9 @@
- + + +

Caracteres ingresados: 0