forked from marquez.juan/clase-8-DOM
agrega funcion contruirLista
This commit is contained in:
@@ -77,5 +77,30 @@ const imagen = document.querySelector("img");
|
||||
|
||||
console.log(imagen.getAttribute("src"));
|
||||
imagen.setAttribute("src", "foto2.jpg");
|
||||
imagen.setAttribute("alt", "locro")
|
||||
imagen.setAttribute("alt", "locro");
|
||||
//ejercicio 8
|
||||
|
||||
const arrayComidas = ["Comidas mendocinas", "Sopaipilla", "Vino tinto"];
|
||||
|
||||
function construirLista(array){
|
||||
|
||||
const creaDiv = document.createElement("div");
|
||||
creaDiv.classList.add("grupo-comidas");
|
||||
|
||||
const h2 = document.createElement("h2");
|
||||
h2.textContent = array[0];
|
||||
|
||||
creaDiv.appendChild(h2);
|
||||
|
||||
const ul = document.createElement("ul");
|
||||
|
||||
for (let i = 1; i< array.length; i++){
|
||||
|
||||
const li = document.createElement("li");
|
||||
li.textContent = array[i];
|
||||
ul.appendChild(li);
|
||||
|
||||
}
|
||||
creaDiv.appendChild(ul);
|
||||
return creaDiv;
|
||||
}
|
||||
Reference in New Issue
Block a user