forked from marquez.juan/clase-8-DOM
feat: add addItem function to append new items to the list
This commit is contained in:
@@ -14,4 +14,13 @@ const addClass = (a) => {
|
|||||||
list.forEach((item) => {
|
list.forEach((item) => {
|
||||||
item.classList.add(a);
|
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);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user