I have a table #table and I would like every time I make a filter by select it adds the amount that is in column 6 eq (5) . With the code below it is running, however it displays the previous value that I select. For example, you are displaying 3 lines with 5, 5, and 5 in each of them. When I change option from select to any other option, then it will show me the sum, 25 on the console.
$('select').on('change', function() {
var qtd = 0
$("#tabela tbody tr:not(.filtered)").each(function(){
qtd += parseInt($(this).find('td').eq(5).html())
});
console.log(qtd);
});
What event could I use to calculate it when I change the selection of <select>
. I had thought of the obvious, the change .
I'm a beginner with jQuery, so if the code can be written in a better way, feel free to suggest it.
Thank you.