Sum of values from different divs Jquery | Codexpress Programming Blog - Tutorials about, PHP, MySQL and Web Development -->

Sum of values from different divs Jquery

   I am loading dynamically divs that have a .totalprice class. At the end, It will sum of the values from all of the .totalprice.

For <div> Elements:

<div class='totalprice'>1.25</div>
 <div class='totalprice'>0.25</div>
 <div class='totalprice'>3.00</div>
 <div class='totalprice'>2.50</div>
 <div class='totalprice'>0.01</div>

 var sum = 0.0;
     sum += parseFloat($(this).text());

For <input> Elements (inputs, checkboxes, etc.):
Alternatively, if you are looking for an integer, you can use the parseInt() function.
see working demo