我的jquery函数有问题我使用了一个函数。我想用减去" - " 来设置答案,使用jquery函数签名。
在我的" totalAmt" 类中,我想用此函数结果设置减号..
function finalRate()
{
var rate = $('.rate').val() != '' ? $('.rate').val() : 0;
var diff = $('.diff').val() != '' ? $('.diff').val() : 0;
var diffAmt = $('.diffAmt').val() != '' ? $('.diffAmt').val() : 0;
var kg = $('.kg').val() != '' ? $('.kg').val() : 0;
var gorssRate = 0;
var totalAmt = 0;
var total = 0;
if(diff == '-')
{
gorssRate = (parseFloat(rate) - parseFloat(diffAmt));
totalAmt = (parseFloat(gorssRate) * parseFloat(kg));
$('.total').val(gorssRate.toFixed(2));
$('.totalAmt').val(totalAmt.toFixed(2));
}
else
{
gorssRate = (parseFloat(rate) + parseFloat(diffAmt));
totalAmt = (parseFloat(gorssRate) * parseFloat(kg));
$('.total').val(gorssRate.toFixed(2));
$('.totalAmt').val(totalAmt.toFixed(2));
}
}