diff --git a/clase-9.js b/clase-9.js index f4c308a..adcaf14 100644 --- a/clase-9.js +++ b/clase-9.js @@ -16,4 +16,17 @@ let Letras = 0; cajaTexto.addEventListener("input", () => { Letras += 1; conatdorLetras.textContent = `Letras escritas = ${Letras} `; +}); + +3// +const lista = document.getElementById("ListaMarcasExoticas"); +lista.addEventListener("click", function(evento) { + if (evento.target.tagName ==="LI") { + const itemPrevio = lista.querySelector(".seleccionado"); + if (itemPrevio) { + itemPrevio.classList.remove("seleccionado"); + } + evento.target.classList.add("seleccionado"); + + } }); \ No newline at end of file diff --git a/estilo.css b/estilo.css index 19d93f8..eb182bf 100644 --- a/estilo.css +++ b/estilo.css @@ -3,3 +3,6 @@ div { padding: 10px; margin: 10px; } +.seleccionado{ + background-color:blue; +} \ No newline at end of file diff --git a/index.html b/index.html index 906a392..f06dc49 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,13 @@
-
+