forked from marquez.juan/clase-8-DOM
33 lines
885 B
JavaScript
33 lines
885 B
JavaScript
// 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");
|
|
}
|
|
} |