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.
|
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
||||||
|
|
||||||
|
// ejercicio 1
|
||||||
|
|
||||||
console.log("El archivo esta vinculado correctamente.")
|
console.log("El archivo esta vinculado correctamente.")
|
||||||
|
|
||||||
const parrafo = document.querySelector("h1");
|
const parrafo = document.querySelector("h1");
|
||||||
console.log(parrafo.textContent);
|
console.log(parrafo.textContent);
|
||||||
parrafo.textContent = "Hola a todos!";
|
parrafo.textContent = "Hola a todos!";
|
||||||
|
|
||||||
|
/* ejercicio 2 */
|
||||||
|
|
||||||
function agregarLista() {
|
function agregarLista() {
|
||||||
const items = document.querySelectorAll(".lista-comidas");
|
const items = document.querySelectorAll(".lista-comidas");
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
@@ -12,6 +17,8 @@ function agregarLista() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ejercicio 3 */
|
||||||
|
|
||||||
const lista = document.querySelector("ul");
|
const lista = document.querySelector("ul");
|
||||||
|
|
||||||
function agregarItem(){
|
function agregarItem(){
|
||||||
@@ -19,4 +26,17 @@ const lista = document.querySelector("ul");
|
|||||||
let itemAgregado = prompt("Ingresa un nuevo item");
|
let itemAgregado = prompt("Ingresa un nuevo item");
|
||||||
nuevoItem.textContent = itemAgregado;
|
nuevoItem.textContent = itemAgregado;
|
||||||
lista.appendChild(nuevoItem);
|
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