构建包含2行和5列的html表的最佳方法是什么?
答案 0 :(得分:3)
使用html:
$('<table> <!-- more html here --> </table>').appendTo(document.body);
答案 1 :(得分:0)
这是一种很好的动态方式。
function createTable(columns, rows) {
var table = $("<table></table>");
var row;
for (i = 0; i < rows; i ++) {
row = $("<tr></tr>");
for (j = 0; j < columns; j ++) {
row.append($("<td></td>"));
}
table.append(row);
}
return table;
}
$(document).ready(function() {
$(body).append(createTable(5,2));
});