I try to make a table in HTML and want to boost it with jQuery .
The table is static and I wish firstly to the first column I call " Index " generate an index list with a for loop. For a visual like this:
Indice | champs 1 | champs 2 | champs 3 |
1
2
3
4
...
My table has identifier id ="balance"
, and the rest of the fields of the table I want to generate after .
Code I tried:
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>