diff --git a/clase-9.js b/clase-9.js index 26ff756..44fecf1 100644 --- a/clase-9.js +++ b/clase-9.js @@ -26,7 +26,23 @@ boton.addEventListener("click", () => { } else { document.getElementById("descripcionCantidad").textContent = "veces."; - + } +}) + +/* + +2. Agregar un campo de texto a la página. A medida que el usuario escribe, + mostrar en tiempo real la cantidad de caracteres ingresados debajo del campo. + +*/ + +const inputTexto = document.getElementById("texto"); + +inputTexto.addEventListener("input", () => { + + let cantidad = inputTexto.value.length; + + document.getElementById("cantidadCaracteres").textContent = cantidad; }) \ No newline at end of file diff --git a/index.html b/index.html index 8abeff5..009bf60 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,12 @@
+ Cantidad de caracteres: + 0 +