I am creating an invoice table where I have a table with the same class. I want to calculate the percent of the same row to find out each product's discounted price and display it to test_sum
after that calculate the total sum and display it to total_sum
. Guys, I need help on this.
<tr>
<td class="test_charge">50</td>
<td class="test_discount">10</td>
<td class="test_sum">Sum:</td>
</tr>
<tr>
<td class="test_charge">40</td>
<td class="test_discount">5</td>
<td class="test_sum">Sum:</td>
</tr>
<tr>
<td class="total_sum">Total: </td>
</tr>
This is my code which is not working:
var sum = 0.0;
$('.test_sum').each(function()
{
sum += parseFloat($(this).html());
});
$('.total_sum').html(sum);
sorry for a previous silly mistake where I have used id, I have replaced it with class
.