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()"
In this the onmouseover event my const keyword in javascript is not working. or else the on each time onmouseover TaxDeduction value gets increased.
您错过了return
:
return parseFloat($('#TaxDeduction').val());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.