+ 1
How to calculate total of a table?
Look at this table. https://code.sololearn.com/W1e2gaCMCxpp/#css Daily expenses are not stable its must change everyday. If the value of price change it should automatically calculate the total. How I can do this with javascript?
2 Respuestas
+ 2
function getTotal() {
    var prices = document.querySelectorAll("tbody tr td:nth-of-type(4)");
    var total = document.querySelector("tfoot tr td:nth-of-type(4)");
    var sum = 0;
    for(price of prices) sum += parseInt(price.innerText, 10);
    total.innerText = sum;
}
getTotal();
https://code.sololearn.com/WSLm3LY3MUj1/?ref=app
+ 1
thanks



