2
would like a help.
I have the following code:
var totalBruto = 0;
var tot_desconto_vlr = 0;
var total = 0;
var totalLiquido = 0;
$(document).ready(function () {
$(".desc_vlr").on("input", function () {
totalBruto = $("#tot_bruto").val();
tot_desconto_vlr = $(this).val();
total = totalBruto + tot_desconto_vlr;
console.info(total);
var tot_liquido = $(this).attr("desconto");
$("#" + tot_liquido).val(total);
});
});
Instead of summing it, he concatenates it by example: 2 + 2 = 22
I wonder what I’m doing wrong so it can add up instead of concatenate.
From now on, thank you !!
Basically
.val()
returns a string. You have to useparseFloat
,Number
orparseInt
.– Sergio