forked from marquez.juan/clase-8-DOM
ejercicio 4
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
||||
|
||||
// ejercicio 1
|
||||
|
||||
console.log("El archivo esta vinculado correctamente.")
|
||||
|
||||
const parrafo = document.querySelector("h1");
|
||||
console.log(parrafo.textContent);
|
||||
parrafo.textContent = "Hola a todos!";
|
||||
|
||||
/* ejercicio 2 */
|
||||
|
||||
function agregarLista() {
|
||||
const items = document.querySelectorAll(".lista-comidas");
|
||||
for (const item of items) {
|
||||
@@ -12,6 +17,8 @@ function agregarLista() {
|
||||
}
|
||||
}
|
||||
|
||||
/* ejercicio 3 */
|
||||
|
||||
const lista = document.querySelector("ul");
|
||||
|
||||
function agregarItem(){
|
||||
@@ -20,3 +27,16 @@ const lista = document.querySelector("ul");
|
||||
nuevoItem.textContent = itemAgregado;
|
||||
lista.appendChild(nuevoItem);
|
||||
}
|
||||
|
||||
//ejercicio 4
|
||||
|
||||
const contenedor = document.getElementById("parrafos");
|
||||
|
||||
if(contenedor){
|
||||
const oracion = contenedor.querySelectorAll("p");
|
||||
const parrafosImportantes = Array.from(oracion).filter(palabra => palabra.textContent.toLowerCase().includes("importante"));
|
||||
|
||||
parrafosImportantes.forEach(parrafo => {
|
||||
parrafo.classList.add("destacado");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user