ejercicio 8

This commit is contained in:
Nicolas Murua
2026-05-13 21:08:34 -03:00
parent 960bf48a59
commit 3b0d27b79f

View File

@@ -77,4 +77,29 @@ function cambiarFoto(foto, texto){
const imagen = document.querySelector("#foto"); const imagen = document.querySelector("#foto");
imagen.setAttribute("src", foto); imagen.setAttribute("src", foto);
imagen.setAttribute("alt", texto); imagen.setAttribute("alt", texto);
}
function construirLista(items){
const contenedor = document.createElement("div");
const titulo = document.createElement("h2");
titulo.textContent = "Lista dinámica";
const lista = document.createElement("ul");
for (const item of items){
const li = document.createElement("li");
li.textContent = item;
lista.appendChild(li);
}
contenedor.appendChild(titulo);
contenedor.appendChild(lista);
document.body.appendChild(contenedor);
contenedor.classList.add("grupo-comidas");
return contenedor;
} }