ejercicio 2: contador de caracteres en tiempo real
This commit is contained in:
@@ -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}`;
|
||||
});
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user