From ee4770f32ca54f5a4381a4cddd9b0687d2a57542 Mon Sep 17 00:00:00 2001 From: Sergio Madera De Marco <37299705@terciariourquiza.edu.ar> Date: Thu, 28 May 2026 13:27:31 -0300 Subject: [PATCH] ejercicio 3: resaltador de items con delegacion de eventos --- ejercicio3/ejercicio3.js | 12 +++++++++++- ejercicio3/estilo.css | 5 +++++ ejercicio3/index.html | 11 ++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ejercicio3/ejercicio3.js b/ejercicio3/ejercicio3.js index 6ce9e92..de82d59 100644 --- a/ejercicio3/ejercicio3.js +++ b/ejercicio3/ejercicio3.js @@ -1 +1,11 @@ -// Agregar aquí el código javascript +const listaItems = document.getElementById('lista-items'); + +listaItems.addEventListener('click', (event) => { + const item = event.target; + + if (item.tagName.toLowerCase() !== 'li') { + return; + } + + item.classList.toggle('seleccionado'); +}); \ No newline at end of file diff --git a/ejercicio3/estilo.css b/ejercicio3/estilo.css index 159b7f6..0c7eb9d 100644 --- a/ejercicio3/estilo.css +++ b/ejercicio3/estilo.css @@ -1,2 +1,7 @@ /* Agregar el código CSS necesario para el ejercicio */ +.seleccionado { + background-color: yellow; + font-weight: bold; +} + diff --git a/ejercicio3/index.html b/ejercicio3/index.html index 678d7ee..1e38784 100644 --- a/ejercicio3/index.html +++ b/ejercicio3/index.html @@ -2,13 +2,22 @@
- +