<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="./jquery.min.js"></script>
</head>
<body>
<button onclick="deleteDate()">删除一个元素</button>
<div id="app"></div>
<script>
let arr = [1, 2, 3, 4, 5];
function renderDOM() {
$("#app").children().remove();
for (let i = 0; i < arr.length; i++) {
let data = arr[i];
$("#app").append(`<p> ${data}</p>`);
}
}
renderDOM();
function deleteDate() {
arr.splice(3, 1);
renderDOM();
}
</script>
</body>
</html>