ejercicio 2: contador de caracteres en tiempo real

This commit is contained in:
2026-05-24 14:44:53 -03:00
parent 63f8bb23a3
commit e2d03163cb
2 changed files with 11 additions and 1 deletions

View File

@@ -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}`;
});

View File

@@ -14,7 +14,9 @@
</div>
<hr>
<div id="ejercicio-2">
<!-- Agregar acá el código HTML que haga falta para el ejercicio 2 -->
<label for="campoTexto">Escribe algo:</label>
<input type="text" id="campoTexto" />
<p id="contadorCaracteres">Caracteres ingresados: 0</p>
</div>
<hr>
<div id="ejercicio-3">