This commit is contained in:
rou
2026-03-23 14:56:04 +08:00
parent 00d3c9e4c6
commit 1071f4db05
27 changed files with 549 additions and 50 deletions

View File

@@ -1,4 +1,22 @@
// 任务:
// 1. 获取新增按钮、删除按钮和列表
// 2. 点击新增按钮时创建一个新的 li 并追加到列表
// 3. 点击删除按钮时删除最后一个 li
const add = document.getElementById("add-btn")
const remove = document.getElementById("remove-btn")
const list = document.getElementById("task-list")
add.onclick = function () {
const a = document.createElement("li")
a.textContent = "巧克力"
list.appendChild(a)
}
remove.onclick = function () {
const c = list.lastElementChild
if (c) {
c.remove()
}
}