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.