forked from marquez.juan/clase-8-DOM
Compare commits
7 Commits
main
...
42a6ea10b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42a6ea10b5 | ||
|
|
005d201af1 | ||
|
|
c45bb28879 | ||
|
|
306801b449 | ||
|
|
b50d8a2bb6 | ||
|
|
09c0b0afc7 | ||
|
|
66ba54e04c |
@@ -1 +1,81 @@
|
|||||||
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
||||||
|
// ejercicio 1
|
||||||
|
function cambiarTitulo() {
|
||||||
|
const titulo = document.querySelector("h1");
|
||||||
|
titulo.textContent = "Comida Argentina";
|
||||||
|
}
|
||||||
|
//ejercicio 2
|
||||||
|
function itemlista() {
|
||||||
|
const item = document.querySelectorAll("ul li");
|
||||||
|
for (const p of item) {
|
||||||
|
p.classList.add("item-lista");
|
||||||
|
console.log("Clase agregada a:", p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ejercicio 3
|
||||||
|
function agregarItem(texto){
|
||||||
|
const lista = document.querySelector("ul");
|
||||||
|
|
||||||
|
const nuevoItem = document.createElement("li");
|
||||||
|
nuevoItem.textContent = texto ;
|
||||||
|
nuevoItem.id= "lista-inicial";
|
||||||
|
lista.appendChild(nuevoItem);
|
||||||
|
console.log("Clase agregada a:", nuevoItem)
|
||||||
|
}
|
||||||
|
//ejercicio 4
|
||||||
|
const parrafos = document.querySelectorAll("#parrafos p");
|
||||||
|
|
||||||
|
for (const p of parrafos) {
|
||||||
|
|
||||||
|
if (p.textContent.includes("importante")) {
|
||||||
|
p.classList.add("destacado");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ejercicio 5
|
||||||
|
function agregarDiv() {
|
||||||
|
const nuevoDiv = document.createElement("div");
|
||||||
|
nuevoDiv.classList.add("grupo-comidas")
|
||||||
|
|
||||||
|
const nuevoh2 = document.createElement("h2");
|
||||||
|
nuevoh2.textContent = "Comidas tipicas de la region del litoral";
|
||||||
|
|
||||||
|
const pintroductorio = document.createElement("p");
|
||||||
|
pintroductorio.textContent = "Estas son algunas comidas tradicionales de la región del litoral argentino.";
|
||||||
|
pintroductorio.classList.add("teto-inicial")
|
||||||
|
|
||||||
|
const nuevoul = document.createElement("ul");
|
||||||
|
nuevoul.classList.add("lista-comida")
|
||||||
|
|
||||||
|
const comida1 = document.createElement("li");
|
||||||
|
comida1.textContent = "Chipa";
|
||||||
|
|
||||||
|
const comida2 = document.createElement("li");
|
||||||
|
comida2.textContent = "Surubi";
|
||||||
|
|
||||||
|
const comida3 = document.createElement("li");
|
||||||
|
comida3.textContent = "Mbaipy";
|
||||||
|
|
||||||
|
nuevoul.appendChild(comida1);
|
||||||
|
nuevoul.appendChild(comida2);
|
||||||
|
nuevoul.appendChild(comida3);
|
||||||
|
|
||||||
|
nuevoDiv.appendChild(nuevoh2);
|
||||||
|
nuevoDiv.appendChild(pintroductorio);
|
||||||
|
nuevoDiv.appendChild(nuevoul);
|
||||||
|
|
||||||
|
document.body.appendChild(nuevoDiv);
|
||||||
|
}
|
||||||
|
//ejercicio 6
|
||||||
|
function limpiarLista(idLista){
|
||||||
|
const borrador = document.querySelectorAll(`#${idLista} li`)
|
||||||
|
for (const li of borrador){
|
||||||
|
li.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ejercicio 7
|
||||||
|
const imagen = document.querySelector("img");
|
||||||
|
|
||||||
|
console.log(imagen.getAttribute("src"));
|
||||||
|
imagen.setAttribute("src", "foto2.jpg");
|
||||||
|
imagen.setAttribute("alt", "locro")
|
||||||
|
//ejercicio 8
|
||||||
@@ -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-clase-8.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user