我尝试用HTML制作表格,并希望使用jQuery增强表格。
该表是静态的,我希望首先在第一列中称为“ Index”,以生成带有for循环的索引列表。对于这样的视觉效果:
Indice | champs 1 | champs 2 | champs 3 |
1
2
3
4
...
我的表具有标识符id ="balance"
,之后还要生成表的其余字段。
我试过的代码:
for (i = 1; i <= 8; i++) {
$('.bilan td:first-child').append("<td><strong>" + i + "</strong></td>");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table class="bilan" cellspacing="0">
<tr>
<td><strong>Indice</strong></td>
<td><strong>Comptoir</strong></td>
<td><strong>Nb commandes</strong></td>
<td><strong>CA (€)</strong></td>
<td><strong>% CA</strong></td>
<td><strong>Nouveaux clients</strong></td>
</tr>
</table>
也许你是说
for (i = 1; i <= 8; i++) {
$(".bilan").append("<tr><td><strong>" + i + "</strong></td></tr>");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table class="bilan" cellspacing="0">
<tr>
<td><strong>Indice</strong></td>
<td><strong>Comptoir</strong></td>
<td><strong>Nb commandes</strong></td>
<td><strong>CA (€)</strong></td>
<td><strong>% CA</strong></td>
<td><strong>Nouveaux clients</strong></td>
</tr>
</table>
或更好。
for (i = 1; i <= 8; i++) {
$(".bilan tbody").append("<tr><td><strong>" + i + "</strong></td></tr>");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table class="bilan" cellspacing="0">
<thead>
<tr>
<th>Indice</th>
<th>Comptoir</th>
<th>Nb commandes</th>
<th>CA (€)</th>
<th>% CA</th>
<th>Nouveaux clients</th>
</tr>
</thead>
<tbody></tbody>
</table>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句