1 回答

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊
你需要改變兩件事:
添加一個(gè) } 關(guān)閉函數(shù)
將row += "<tr>";(未聲明的變量)更改為table += "<tr>";
gangetabellen()
<div id="tabell"></div>
<script>
function gangetabellen() {
var tall1, tall2, produkt;
var tabell = "<table style='width:500px'>";
// If you want a header you should add a for-loop here to add
// a row with tall2
for (tall1 = 10; tall1 <= 19; tall1++) {
tabell += "<tr>";
// If you want a header to the left you should add it here.
for (tall2 = 1; tall2 <= 19; tall2++) {
produkt = tall1 * tall2;
tabell += "<td>" + produkt + "</td>";
}
tabell += "</tr>";
}
tabell += "</table>";
document.getElementById("tabell").innerHTML = tabell;
}
</script>
如果你想在邊緣顯示tall1,tall2你需要為此添加代碼(并且你可以使用<th>而不是<td>“表格標(biāo)題”。它可以更容易地設(shè)置表格的樣式。
添加回答
舉報(bào)