一、效果
二、HTML代码
<h3>动态组装表格,点击一次,一次性生成一个四行六列的表格。</h3><br />
<button type="button" id="insert">增加</button>
<table class="table">
<thead></thead>
<tbody></tbody>
</table>
三、css
<style>
.table tr {
border-style: solid;
}
.table td {
width: 100px;
height: 20px;
border-style: solid;
}
</style>
四、js
$("#insert").click(function () {
//$(".table tbody").empty();
for (var j = 0; j < 4; j++) {
var hang = $("<tr></tr>");
for (var i = 0; i < 6; i++) {
$("<td></td>").append("td" + i).appendTo(hang);
}
$(".table tbody").append(hang);
}
})