Calculer la somme d'une colonne d'un tableau html
Bonjour, je souhaiterais calculer la somme de toutes les colonnes "temps (min)" de mon tableau html ci-joint.
Serait-il possible de m'orienter vers un bout de code js à appliquer ?
Le code devrait prendre en compte l'ajout de nouvelles lignes à mon tableau dans le futur
Le plus facile serait que cette valeur (total de la somme) puisse être écrite en html ensuite avec ce code La somme = <span id="sum"></span> et donc il faudra j'imagine retrouver dans le code js la ligne suivante document.getElementById("sum").innerHTML=somme;Merci d'avance.
Le tableau
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <table id="support" class="supporttable">
<tbody>
<tr>
<th style="width: 5.28053%;">Id</th>
<th style="width: 26.0726%;">Date</th>
<th id="temps" style="width: 15.5116%;">Temps (min)</th>
<th style="width: 49.1749%;">Description</th>
</tr>
<tr>
<td style="width: 5.28053%;">3</td>
<td style="width: 26.0726%;">10/07/2020</td>
<td id="temps" style="width: 15.5116%;">1</td>
<td style="width: 49.1749%;">autre</td>
</tr>
<tr>
<td style="width: 5.28053%;">2</td>
<td style="width: 26.0726%;">10/07/2020</td>
<td style="width: 15.5116%;">1</td>
<td style="width: 49.1749%;">autre</td>
</tr>
<tr>
<td style="width: 5.28053%;">1</td>
<td style="width: 26.0726%;">10/07/2020</td>
<td style="width: 15.5116%;">27</td>
<td style="width: 49.1749%;">Mise à jour</td>
</tr>
</tbody>
</table> |