0
I don’t understand why I can’t run the following script because I’m a bit of a layman:
<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>
</div>
<div id="subtotal"></div>
and the script...
$(document).ready( function() {
$('#option-1, #option-2').blur(function(){
var sum = $('#option-1').text();
var sum2 = $('#option-2').text();
if(sum == "") sum = 0;
if(sum2 == "") sum2 = 0;
var resultado = parseInt(sum) + parseInt(sum2);
$("#subtotal").text(resultado);
})
});
Or if you have some simpler way to do this function but need to specify each div.
Any error appears in the console?
– Guilherme Nascimento
No mistake :((
– Leonardo Ferreira
These values can be changed dynamically?
– Guilherme Nascimento