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);
});
}