The script is adding, but only numbers. I would like to have the values with periods and commas.
For example: 1,000.00 + 100.00 = 1.100.00
Does anyone give this strength there?
Follow the code below:
<script src="jquery_somar.js"></script>
<div class="somar">1.000,00</div>
<div class="somar">1.000,00</div>
<div class="somar">1.000,00</div>
<div id="resultado">3.000,00</div>
<script type="text/javascript">
var sum = 0;
$('.somar').text(function(i, v) {
sum += parseFloat(v.replace(',', '.'));
});
$('#resultado').text('resultado : ' + sum);
</script>