I have a function that performs a calculation and changes the value of my component. But I would like it to return the value in Reals already with the Mask, I am using MaskMoney
but it is returning NaN
. Can anyone help me?
Follow the function:
function retornaResultado(num) {
// Recupera valores
var iuc = document.querySelector("#iuc");
var gi = document.querySelector("#gi");
var isb = document.querySelector("#isb");
var cap = document.querySelector("#cap");
var ca = document.querySelector("#ca");
/*Tentando adicionar a máscara no campo*/
$(document).ready(function() {
$("#ca").maskMoney({
showSymbol: true,
symbol: "R$",
decimal: ",",
thousands: "."
});
});
//Realiza Cálculo
var risb = calculoISB();
var rcap = calculoCAP();
var calcgi = parseFloat(risb) + parseFloat(rcap) + parseFloat(iuc.value);
gi.textContent = calcgi.toFixed(3);
isb.textContent = calculoISB();
cap.textContent = calculoCAP();
var result = calcgi * num;
/* Aqui fica o campo no qual quero alterar o valor já com a mask(R$)*/
ca.textContent = result.toFixed(2);
}