24 lines
604 B
JavaScript
24 lines
604 B
JavaScript
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
|
|
|
// Ejercicio 1
|
|
const changeText = (str) => {
|
|
const h1 = document.querySelector("h1");
|
|
h1.textContent = str;
|
|
}
|
|
|
|
// Ejercicio 2
|
|
const addClass = (className) => {
|
|
const itemLista = document.querySelectorAll("li");
|
|
itemLista.forEach((item) => {
|
|
item.classList.add(className);
|
|
});
|
|
}
|
|
|
|
// Ejercicio 3
|
|
const agregarItem = (text) =>{
|
|
const list = document.querySelector("#lista-inicial");
|
|
const newLi = document.createElement("li");
|
|
newLi.textContent = text;
|
|
list.appendChild(newLi);
|
|
}
|