forked from marquez.juan/clase-8-DOM
ejercicio 8
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user