I have three div that contain a number.
<div class="a">10</div>
<div class="b">20</div>
<div class="c">30</div>
I get the number inside each one with jQuery .html().
var val_1 = $('.a').html(),
val_2 = $('.b').html(),
val_3 = $('.c').html();
How can I sum them?
This do not work as expected:
var total = val_1 + val_2 + val_3;
Since returned 102030, when I expected 60.
var val_1 = parseInt($('.a').html(), 10);In JavaScript,+is both addition and string concatenation ("addition").