Seleccione todos los parrafos dentro del div y si un parrafo tenia la palabra importante le agregue la clase destacado
This commit is contained in:
@@ -19,4 +19,14 @@ function agregarItem(texto) {
|
|||||||
nuevaLista.textContent = texto;
|
nuevaLista.textContent = texto;
|
||||||
|
|
||||||
lista.appendChild(nuevaLista);
|
lista.appendChild(nuevaLista);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parrafos = document.querySelectorAll("#parrafos p");
|
||||||
|
|
||||||
|
for (const p of parrafos) {
|
||||||
|
|
||||||
|
if (p.textContent.includes("importante")) {
|
||||||
|
p.classList.add("destacado");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user