I need somehow to sum up the text values from the span, but I only can extract them and not to sum up. Is there a way to do this correctly? I got blocked about the code, I'm new to jQuery.
Demo: http://jsfiddle.net/0L4s6g8p/1/
Html:
<div class="prices">
<h3>Option 1 = $<span class="sum" id="option-1">11.11</span></h3>
<h3>Option 2 = $<span class="sum" id="option-2">22.22</span></h3>
<h3>Option 3 = $<span class="sum" id="option-3">33.33</span></h3>
</div>
<h3>Subtotal = $<span id="subtotal">0.00</span></h3>
Script:
$('.prices').each(function(){
var sum = $('.sum').text();
$(this).each(function(){
sum += parseInt($('.sum').text());
});
$("#subtotal").text(sum);
});