I am loading dynamically divs that have a .totalprice class. At the end, I would like to sum of the values from all of the .totalprice.
.totalprice
for non input elements:
var sum = 0; $('.totprice').each(function(){ sum = parseFloat(sum) + parseFloat($(this).text()); }); alert(sum);
for input elements:
var sum = 0; $('.totprice').each(function(){ sum = parseFloat(sum) + parseFloat(this.value); }); alert(sum);