ejercicio 4: destacar parrafos importantes con classList
This commit is contained in:
@@ -27,4 +27,15 @@ function agregarItem(texto) {
|
||||
nuevoItem.textContent = texto;
|
||||
|
||||
lista.appendChild(nuevoItem);
|
||||
}
|
||||
// 4
|
||||
|
||||
function destacarParrafos() {
|
||||
const parrafos = document.querySelectorAll("#parrafos p");
|
||||
|
||||
for (const parrafo of parrafos) {
|
||||
if (parrafo.textContent.includes("importante")) {
|
||||
parrafo.classList.add("destacado");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user