[英]javascript const keyword is not working
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值都會增加。
您錯過了return
:
return parseFloat($('#TaxDeduction').val());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.