From d2c918537fd8923287efd7159210a34f6ebbc321 Mon Sep 17 00:00:00 2001 From: Bruno Date: Wed, 27 May 2026 20:21:45 -0300 Subject: [PATCH] Resolucion del 3er ejercicio --- clase-9.js | 14 +++++++++++++- estilo.css | 6 ++++++ index.html | 8 +++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/clase-9.js b/clase-9.js index d7418b1..926bc76 100644 --- a/clase-9.js +++ b/clase-9.js @@ -13,4 +13,16 @@ const resultado = document.querySelector("#resultado"); campo.addEventListener("input", () => { const cantidad = campo.value.length; resultado.textContent = `Caracteres: ${cantidad}`; -}) \ No newline at end of file +}) + +//ejercicio 3 +const lista = document.querySelector("#lista"); +lista.addEventListener("click", (e) => { + if (e.target.tagName === "LI") { + const yaSeleccionado = document.querySelector(".seleccionado"); + if (yaSeleccionado) { + yaSeleccionado.classList.remove("seleccionado"); + } + e.target.classList.add("seleccionado"); + } +}); \ No newline at end of file diff --git a/estilo.css b/estilo.css index 19d93f8..2166a6f 100644 --- a/estilo.css +++ b/estilo.css @@ -3,3 +3,9 @@ div { padding: 10px; margin: 10px; } + +li.seleccionado { + background-color: blue; + color: white; + font-weight: bold; +} \ No newline at end of file diff --git a/index.html b/index.html index 142cc6f..71c83c4 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,13 @@
- +