function sumTable() {
// Select the table element
var $table = $('#myTable');
//// Create a new row element
var $newRow = $('<tr style="font-weight:bold"><td colspan="5"></td>');
// i want from 5th to 26th column only
// Iterate through the columns that you want to sum
for (var i = 5; i < 26; i++) {
var sum = 0;
// Sum the values of the cells in the column
$table.find('tr td:nth-child(' + (i + 1) + ')').each(function() {
sum += parseInt($(this).html());
});
$newRow.append($('<td>').html(sum));
// Add the sum to a new cell in the new row
}
$('#table_body').append($newRow);
}
как получить сумму отдельных столбцов HTML-таблицы с помощью j-запроса
schedule
27.06.2024