forked from marquez.juan/clase-8-DOM
ejercicio 8
This commit is contained in:
@@ -78,3 +78,28 @@ function cambiarFoto(foto, texto){
|
||||
imagen.setAttribute("src", foto);
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user