I have an HTML table with number values. What I need to do is to get all these values and add them together using jQuery.
Any ideas?
Example table:
I have an HTML table with number values. What I need to do is to get all these values and add them together using jQuery.
Any ideas?
Example table:
You can call
.each
:It's already been answered. So just as a fun exercise:
I'm going to give you some pseudo-code of how I would do it (mainly because I can't be stuffed writing the whole thing).
.each()
to loop through eachtr
.td
and add the value to the relevant total.tr
have been looped through, do whatever you want :)Hope this helps you out :)
EDIT: I was writing the code as if you wanted to total each column, rather than all cells into a single total.