diff --git a/ejercicios-clase-8.js b/ejercicios-clase-8.js index af39c43..e191e6f 100644 --- a/ejercicios-clase-8.js +++ b/ejercicios-clase-8.js @@ -1 +1,100 @@ // 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'); + } + }); +} + +// Ejercicio 5 + +const newSection = () => { + const body = document.querySelector('body'); + const div = document.createElement('div'); + body.appendChild(div); + + const h2 = document.createElement('h2'); + h2.textContent = 'Comidas tipidas del Litoral'; + div.appendChild(h2); + + const parragraph = document.createElement('p'); + parragraph.textContent = 'El litoral argentino es conocido por su rica gastronomía, que incluye platos típicos como el surubí a la parrilla, el pacú al horno, la boga frita y el chivito al plato. Estos platos reflejan la diversidad de ingredientes y sabores que se encuentran en la región, y son una parte importante de la cultura culinaria del litoral.'; + div.appendChild(parragraph); + + const list = document.createElement('ul'); + const items = ['Surubí a la parrilla', 'Pacú al horno', 'Boga frita', 'Chivito al plato']; + items.forEach((item) => { + const li = document.createElement('li'); + li.textContent = item; + list.appendChild(li); + }); + div.appendChild(list); +} + +// Ejercicio 6 + +const cleanList = (id) => { + const list = document.getElementById(id); + while (list.firstChild) { + list.removeChild(list.firstChild); + } +} + +// Ejercicio 7 + +const changeImage = () => { + const image = document.querySelector('img'); + image.src = "foto2.jpg"; + image.alt = 'Locro';} + +// Ejercicio 8 + +const buildList = (arr) => { + const div = document.createElement('div'); + div.classList.add('grupo-comidas'); + + const h2 = document.createElement('h2'); + h2.textContent = arr[0]; + div.appendChild(h2); + + const ul = document.createElement('ul'); + + for (let i = 1; i < arr.length; i++) { + const li = document.createElement('li'); + li.textContent = arr[i]; + ul.appendChild(li); + } + + div.appendChild(ul); + return div; +}; \ No newline at end of file diff --git a/estilo.css b/estilo.css index fcb26fc..e55df68 100644 --- a/estilo.css +++ b/estilo.css @@ -101,6 +101,14 @@ h1 { font-weight: bold; } +/* Clase item-lista */ +.item-lista { + background: #fff4d6; + border-color: #f4b400; + color: #7a5200; + font-weight: bold; +} + /* ========================= IMAGEN ========================= */ diff --git a/index.html b/index.html index 0c393ac..dcd25dc 100644 --- a/index.html +++ b/index.html @@ -32,4 +32,5 @@

Este es otro párrafo del montón.

+