59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
|
//ejercicio 1
|
|
function titulo(){
|
|
document.querySelector("h1").textContent = "Gastronomia Argentina";
|
|
}
|
|
//ejercicio 2
|
|
function ejercicio2() {
|
|
const items = document.querySelectorAll("li");
|
|
for (const item of items) {
|
|
item.classList.add("item-lista");
|
|
item.style.color = "red"
|
|
}
|
|
}
|
|
//ejercicio 3
|
|
function agregaritem(comida){
|
|
const lista = document.querySelector("#lista-inicial");
|
|
const nuevoitem = document.createElement("li")
|
|
nuevoitem.textContent = comida;
|
|
lista.appendChild(nuevoitem);
|
|
}
|
|
//ejercicio 4
|
|
const parrafos = document.querySelectorAll("#parrafos p");
|
|
for (const parrafo of parrafos){
|
|
if (parrafo.textContent.includes ("importante"))
|
|
parrafo.classList.add("destacado")
|
|
}
|
|
//ejercicio 5
|
|
function ejercicio5(){
|
|
const seccion = document.createElement("div")
|
|
const titulo = document.createElement("h2")
|
|
titulo.textContent = "comidas típicas de la región del litoral"
|
|
const parrafo = document.createElement("p")
|
|
parrafo.textContent = "La región del litoral argentino se caracteriza por una gastronomía muy influenciada por los ríos, la pesca y las tradiciones guaraníes."
|
|
const lista = document.createElement("ul");
|
|
const item = document.createElement("li");
|
|
item.textContent = "chipa";
|
|
const item2 = document.createElement("li");
|
|
item2.textContent = "pacu asado";
|
|
const item3 = document.createElement("li");
|
|
item3.textContent = "surubi a la parrilla";
|
|
lista.appendChild(item);
|
|
lista.appendChild(item2);
|
|
lista.appendChild(item3);
|
|
seccion.appendChild(titulo)
|
|
seccion.appendChild(parrafo)
|
|
seccion.appendChild(lista)
|
|
document.body.appendChild(seccion)
|
|
}
|
|
//ejercicio 6
|
|
function limpiarlista(){
|
|
const elementos = document.querySelectorAll(`#${idLista} li`)
|
|
for (const elemento of elementos){
|
|
elemento.remove()
|
|
}
|
|
}
|
|
//ejercicio 7
|
|
const imagen = document.querySelector("img")
|
|
imagen.setAttribute("src", "foto2.jpg");
|
|
imagen.setAttribute("alt", "Locro") |