I have a generated table on my JSP that contains data for transactions: each individual transaction is a row, and there\'s a column for category, amount, type, and descripti
Your variable tds
should be named cls
. Here is a working example.
https://jsfiddle.net/34wf5gzs/
for (var i = 0; i < cls.length; i++){
if(cls[i].className == "countable"){
sum += isNaN(cls[i].innerHTML) ? 0 : parseInt(cls[i].innerHTML);
}
}
Roman C is right though. You're better off summing this up using a JS framework or using a counter in JSP. Custom scripts require some effort to maintain.