ejercicio 3: agregar elementos a una lista con createElement
This commit is contained in:
@@ -17,3 +17,14 @@ function destacarComidas() {
|
||||
comida.style.color = "red";
|
||||
}
|
||||
}
|
||||
// 3
|
||||
|
||||
function agregarItem(texto) {
|
||||
const lista = document.querySelector("#lista-inicial");
|
||||
|
||||
const nuevoItem = document.createElement("li");
|
||||
|
||||
nuevoItem.textContent = texto;
|
||||
|
||||
lista.appendChild(nuevoItem);
|
||||
}
|
||||
Reference in New Issue
Block a user