<ul id="myList">
<li>첫 번째 아이템</li>
<li>두 번째 아이템</li>
</ul>
<button id="addItemBtn">아이템 추가</button>
const addButton = document.getElementById("addItemBtn");
addButton.addEventListener("click", addListItem);
function addListItem() {
const myList = document.getElementById("myList");
const newListItem = document.createElement("li");
newListItem.textContent = "새로운 아이템";
myList.appendChild(newListItem);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.