forked from marquez.juan/clase-8-DOM
37 lines
838 B
JavaScript
37 lines
838 B
JavaScript
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
|
|
|
// Ejercicio 1
|
|
|
|
const changeTittle = (a) => {
|
|
const tittle = document.querySelector('h1');
|
|
tittle.textContent = a;
|
|
}
|
|
|
|
// Ejercicio 2
|
|
|
|
const addClass = (a) => {
|
|
const list = document.querySelectorAll('li');
|
|
list.forEach((item) => {
|
|
item.classList.add(a);
|
|
});
|
|
}
|
|
|
|
// Ejercicio 3
|
|
|
|
const addItem = (a) => {
|
|
const list = document.querySelector('ul');
|
|
const newItem = document.createElement('li');
|
|
newItem.textContent = a;
|
|
list.appendChild(newItem);
|
|
}
|
|
|
|
// Ejercicio 4
|
|
|
|
const highlight = () => {
|
|
const paragraphs = document.querySelectorAll('#parrafos p');
|
|
paragraphs.forEach((p) => {
|
|
if (p.textContent.toLowerCase().includes('importante')) {
|
|
p.classList.add('destacado');
|
|
}
|
|
});
|
|
} |