Cree una funcion para agregar una clase personalizada

This commit is contained in:
2026-05-21 18:58:27 -03:00
parent d5979f13db
commit 868cf5a5fd
2 changed files with 16 additions and 0 deletions

View File

@@ -5,3 +5,11 @@ const changeText = (str) => {
const h1 = document.querySelector("h1");
h1.textContent = str;
}
// Ejercicio 2
const addClass = (className) => {
const itemLista = document.querySelectorAll("li");
itemLista.forEach((item) => {
item.classList.add(className);
});
}

View File

@@ -101,6 +101,14 @@ h1 {
font-weight: bold;
}
/* Clase item-lista */
.item-lista {
background: #fff4d6;
border-color: #f4b400;
color: #7a5200;
font-weight: bold;
}
/* =========================
IMAGEN
========================= */