可能重複:
Creating tables dynamically in jQuery生成在JavaScript中的表/ jQuery的
我有兩個陣列,letters = [A,B,C,...]
和numbers = [1,2,3,...]
,並希望產生與numbers
作爲頭一個HTML表格和letters
作爲第一個條目(然後我可以用我有的值填充它)。 這是普通數組可能嗎?
也就是說,如下圖所示:
<table>
<thead>
<tr>
<th></th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr id="A">
<td>A</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr id="B">
<td>B</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr id="C">
<td>C</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
_「這是普通數組可能嗎?」_ - 當然。你試過什麼了? – nnnnnn 2012-07-16 10:52:45
@DrColossos eeep,這「重複」看起來很可怕。 – 2012-07-16 11:00:41
@hayden這不是關於發佈的代碼;)而是在答案中提出的想法......我不會隨時使用作者發佈的代碼,但解決方案是可行的IMO。 – DrColossos 2012-07-16 11:15:18