<table>
<tbody>
<tr>
<td>1</td>
<td class="qty">1</td>
<td class="price">2</td>
<td class="disc">0</td>
<td class="total">2</td>
</tr>
<tr>
<td>2</td>
<td class="qty">2</td>
<td class="price">10</td>
<td class="disc">10</td>
<td class="total">18</td>
</tr>
</tbody>
</table>
$('#table').on('change', function () {
var row = $(this).closest('tr');
var total = 0;
$('#tr', row).each(function() {
total += Number($(this).val());
});
$('.total', row).text(total);
});
I am trying to get the code above to work. I am using the latest version of python. I need to listen to a table for a change so that I can get the last row. The row is added by jquery. The rows are added through out the day. I do not know when they will be added. I do not know how many rows will be added either. What libraries do I need to import to get this to work?