K
K
kavkaz062020-05-03 14:58:25
JavaScript
kavkaz06, 2020-05-03 14:58:25

Need looping logic to loop through all the rows in a table?

Good afternoon! there is a code

var pos =  $(this).closest('#rrr').find('th:last, td:last input').val();

it gives me the sum of a tr line like: (volume*material*work=total) and this is the total he gives me. But I have many such tr
rows and I need the total sum of the last column . how do i use a for loop? the code that I indicated above should remain exactly like this. as there is further action)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2020-05-03
@kavkaz06

var pos = 0;
$(this).closest('#rrr').find('th:last input, td:last input').each(function() {
  pos += +$(this).val();
});
Please note that I corrected the bug in the selector

K
kavkaz06, 2020-05-03
@kavkaz06

I will clarify the question: I have a total for each row of tr in the last column (550.00) (430.00) (700.00) I need to get the Total amount in alert(); 1680.00 and your example displays ( 0550.00 ) to 550.00 in front, zero was added and that's it!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question