forked from marquez.juan/clase-8-DOM
EJ6 terminado
This commit is contained in:
@@ -1,22 +1,67 @@
|
||||
// Vincular este archivo al archivo index.html, y resolver aquí los ejercicios.
|
||||
//1
|
||||
/*
|
||||
const tituloh1 = document.querySelector("h1")
|
||||
console.log(tituloh1.textContent);
|
||||
tituloh1.textContent = "Titulo reemplazado correctamente"
|
||||
|
||||
*/
|
||||
//2
|
||||
/*
|
||||
function List(){
|
||||
const items = document.querySelectorAll("ul li")
|
||||
for (const item of items){
|
||||
item.classList.add("item-lista")
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
//3
|
||||
/*
|
||||
function agregarItem(texto){
|
||||
const nuevoLi = document.createElement("li");
|
||||
nuevoLi.textContent = texto;
|
||||
const lista = document.getElementById("lista-inicial");
|
||||
lista.appendChild(nuevoLi);
|
||||
}
|
||||
|
||||
*/
|
||||
//4
|
||||
/*
|
||||
function div(){
|
||||
const lista_de_parrafos = document.querySelectorAll("#parrafos p");
|
||||
for (const un_parrafo of lista_de_parrafos) {
|
||||
if (un_parrafo.textContent.indexOf("importante") > -1){
|
||||
un_parrafo.classList.add("destacado");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//5
|
||||
/*
|
||||
function nuevoDiv(){
|
||||
const contenedor = document.createElement('div')
|
||||
const titulo = document.createElement('h2')
|
||||
titulo.textContent = 'Sabores de la region del litoral';
|
||||
const parrafo = document.createElement('p');
|
||||
parrafo.textContent = 'Lista de sabores';
|
||||
const lista = document.createElement('li')
|
||||
const comidas = [
|
||||
'Chipa',
|
||||
'Pescado de rio a la parrilla',
|
||||
'Chupin',
|
||||
'Sopa paraguaya'
|
||||
];
|
||||
comidas.forEach(comida => {
|
||||
const item = document.createElement('li');
|
||||
item.textContent = comida;
|
||||
lista.appendChild(item);
|
||||
});
|
||||
}
|
||||
*/
|
||||
//6
|
||||
function limpiarLista(listaInicial){
|
||||
const lista = document.getElementById(listaInicial);
|
||||
if (lista) {
|
||||
lista.innerHTML = ""
|
||||
} else {
|
||||
console.warn(`No se encontró ninguna lista con el id: "${listaInicial}"`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user