forked from marquez.juan/clase-8-DOM
Compare commits
8 Commits
main
...
68407857f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 68407857f3 | |||
| 78e9f0bc76 | |||
| d5fffd0142 | |||
| 2d9a7d037b | |||
| f9fcf5b79c | |||
| ad2f54d04c | |||
| 799a081fbe | |||
| f91489c01d |
74
ejercicios.js
Normal file
74
ejercicios.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// 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")
|
||||||
|
//ejercicio 8
|
||||||
|
function construirLista(listacomidas) {
|
||||||
|
const seccion = document.createElement("div")
|
||||||
|
const titulo = document.createElement("h2")
|
||||||
|
titulo.textContent = "comidas típicas de la región del litoral"
|
||||||
|
const lista = document.createElement("ul");
|
||||||
|
for (const comida of listacomidas){
|
||||||
|
const elemento = document.createElement("li")
|
||||||
|
elemento.textContent = comida
|
||||||
|
lista.appendChild(elemento)
|
||||||
|
}
|
||||||
|
seccion.appendChild(titulo)
|
||||||
|
seccion.appendChild(lista)
|
||||||
|
return seccion
|
||||||
|
}
|
||||||
@@ -31,5 +31,6 @@
|
|||||||
<p>¿Y este párrafo? ¿Será importante?</p>
|
<p>¿Y este párrafo? ¿Será importante?</p>
|
||||||
<p>Este es otro párrafo del montón.</p>
|
<p>Este es otro párrafo del montón.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="ejercicios.js" ></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user