您需要填写表格如下: 我创建了一个表格。我拿了一排,从中取出了细胞。我做了一个金字塔。算错了,但在哪里)
let table = document.querySelector("table");
for (let i = 0; i < 5; i++) {
let newTr = document.createElement("tr");
table.append(newTr);
for (let j = 1; j <= 5; j++) {
let newTd = document.createElement("td");
newTr.append(newTd);
}
}
let allTr = document.querySelectorAll("tr");
var output = "";
for (const tr of allTr) {
for (const td of tr.children) {
for (let i = tr.children.length; i>=1; i--) {
for (var j = 1; j <= i; j++) {
output = 'x'
}
td.textContent = output;
}
}
}
table {
width: 100%;
margin-bottom: 20px;
/* border: 1px solid black; */
/* border-collapse: collapse; */
}
table tr {
font-weight: bold;
padding: 5px;
border: 1px solid black;
}
table td {
border: 1px solid black;
padding: 5px;
height: 40px;
}
<table></table>