my.js
function deductions(){
parseFloat($('#TaxDeduction').val()); // value 5
}
function earning() {
const itdeduction = deductions();
var basicsalary = parseFloat($('#BasicSalary').val()); //value 10000
var da = parseFloat($('#DA').val()); // value 1000
var totalearning = Math.round((basicsalary+da)); // value 11000
var it_deduction = Math.round(((totalearning * itdeduction) / 100)); //value 550
$('#TaxDeduction').html(it_deduction.toFixed(2));
$('#TaxDeduction').val(it_deduction.toFixed(2)); //value 550 on first mouse over //value 60500 on second mouseover. but i Need value 550 for n number of mouseover
}
my.html
onmouseover="earning()"
在这个onmouseover事件中,我在javascript中的const关键字不起作用。或者每次onmouseover TaxDeduction值都会增加。
答案 0 :(得分:0)
您错过了return
:
return parseFloat($('#TaxDeduction').val());