Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 基本jQuery计算器_Javascript_Jquery_Html_Calculator - Fatal编程技术网

Javascript 基本jQuery计算器

Javascript 基本jQuery计算器,javascript,jquery,html,calculator,Javascript,Jquery,Html,Calculator,我正在开发jQuery计算器。直到几分钟前,一切都很顺利,现在什么都不会发生了。我是不是意外地在事故代码中加入了一个坏字符?我上下扫描了好几次,但都找不到来源。任何帮助都将不胜感激 负责人: jQuery: $(document).ready(function() { alert("ready"); $('#salary, #transcribing-hours, #cost-of-assistant').keydown(function(e){ var key = e.which

我正在开发jQuery计算器。直到几分钟前,一切都很顺利,现在什么都不会发生了。我是不是意外地在事故代码中加入了一个坏字符?我上下扫描了好几次,但都找不到来源。任何帮助都将不胜感激

负责人:


jQuery:

$(document).ready(function() {
alert("ready");
 $('#salary, #transcribing-hours, #cost-of-assistant').keydown(function(e){
    var key = e.which;
    if (key != 8 && key != 9 && key != 37 && key != 38 && key != 39 && key != 40 && key != 46 && key != 110 && key != 190 && key != 13){
        if (key < 48){
            e.preventDefault();
        }
        else if (key > 57 && key < 96){
            e.preventDefault();
        }

        else if (key > 105) {
            e.preventDefault();
        }
    }
 });
});

$('#salary').on('input', function() {
    var salary = $('#salary').val();
    var costofassist = $('#cost-of-assistant').val();
    var total = salary / (52 * 40);
    var roundtotal = Math.round(total * 100) / 100;

    $('#hourly-pay-total').text(roundtotal);

});

$('#transcribing-hours').on('input', function() {
    var hoursday = $('#transcribing-hours').val();
    var hoursweek = hoursday * 5;
    var hoursmonth = hoursweek * 4.3;
    var hoursyear = hoursweek * 52;

    $('#transcribing-year').text(Math.round(hoursyear * 100) / 100);
    $('#transcribing-month').text(Math.round(hoursmonth * 100) / 100);
    $('#transcribing-week').text(Math.round(hoursweek * 100) / 100);

    var roundtotal = $('#hourly-pay-total').text();
    var costwithoutyear = (hoursweek * roundtotal) * 52;
    var costwithoutmonth = (hoursweek * roundtotal) * 4.3;
    var costwithoutweek = hoursweek * roundtotal;

    $('#cost-without-year').text(Math.round(costwithoutyear * 100) / 100);
    $('#cost-without-month').text(Math.round(costwithoutmonth * 100) / 100);
    $('#cost-without-week').text(Math.round(costwithoutweek * 100) / 100);

});

$('#cost-of-assistant').on('input', function() {
    var costofassist = $('#cost-of-assistant').val();
    var costwithoutyear = $('#cost-without-year').text();
    var annualsavings = costwithoutyear - costofassist;
    var monthlysavings = annualsavings / 12;
    var weeklysavings = annualsavings / 52;
    var dailysavings = annualsavings / 260;

    $('#annual-savings').text((Math.round(annualsavings * 100) / 100);
    $('#monthly-savings').text(Math.round(monthlysavings * 100) / 100);
    $('#weekly-savings').text(Math.round(weeklysavings * 100) / 100);
    $('#daily-savings').text(Math.round(dailysavings * 100) / 100);
});
$(文档).ready(函数(){
警惕(“准备就绪”);
$(“#工资,#抄写时数,#助理成本”)。按键(功能(e){
var-key=e.which;
如果(键!=8&&key!=9&&key!=37&&key!=38&&key!=39&&key!=40&&key!=46&&key!=110&&key!=190&&key!=13){
如果(键<48){
e、 预防默认值();
}
否则,如果(键>57和键<96){
e、 预防默认值();
}
否则,如果(键>105){
e、 预防默认值();
}
}
});
});
$('#salary')。在('input',function()上{
var salary=$(“#salary”).val();
var costofassist=$(“#助手成本”).val();
风险价值总额=工资/(52*40);
var roundtotal=数学四舍五入(总计*100)/100;
$(“#小时工资总额”)。文本(总计);
});
$(“#转录小时数”)。on('input',function(){
var hoursday=$(“#转录小时数”).val();
var hoursweek=小时天数*5;
var hoursmonth=hoursweek*4.3;
var hoursyear=hoursweek*52;
$(“#转录年份”).text(Math.round(hourswear*100)/100);
$(“#转录月份”).text(Math.round(hoursmonth*100)/100);
$(“#转录周”).text(Math.round(hoursweek*100)/100);
var roundtotal=$(“#小时工资总额”).text();
无年份风险价值成本=(每周小时*总金额)*52;
无月var成本=(小时周*总整数)*4.3;
每周内的风险价值成本=每周小时数*总计;
$(“#无年份成本”).text(数学整数(无年份成本*100)/100);
$(“#无月成本”).text(数学四舍五入(无月成本*100)/100);
$(“#无周成本”).text(Math.round(无周成本*100)/100);
});
$(“#助手成本”)。关于('input',function(){
var costofassist=$(“#助手成本”).val();
无年份的var成本=$(“#无年份的成本”).text();
var AnnualSaveings=无年份成本-辅助成本;
var monthlysavings=年度储蓄/12;
var weeklysavings=年度储蓄/52;
var dailysavings=年度储蓄/260;
$(“#年度储蓄”).text((数学四舍五入(年度储蓄*100)/100);
$(“#每月储蓄”).text(Math.round(monthlysavings*100)/100);
$(“#每周储蓄”).text(Math.round(weeklysavings*100)/100);
$(“#每日储蓄”).text(Math.round(dailysavings*100)/100);
});

jQuery代码第59行的开头括号太多了

 $('#annual-savings').text((Math.round(annualsavings * 100) / 100);
应该是:

 $('#annual-savings').text(Math.round(annualsavings * 100) / 100);

提示:如果您使用例如Firefox或Safari,您就有一个javascript控制台,它可以检测此类语法错误。

jQuery代码第59行的开头括号太多了

 $('#annual-savings').text((Math.round(annualsavings * 100) / 100);
应该是:

 $('#annual-savings').text(Math.round(annualsavings * 100) / 100);

提示:如果您使用Firefox或Safari,您有一个javascript控制台,可以检测此类语法错误。

我使用firebug插件,我对此非常满意。在控制台选项卡中,它会显示类似ok发现的语法错误。我使用mozilla,但我非常确定Chrome也支持它。您应该尝试一下。

我使用firebug插件,对此我非常满意。在控制台选项卡中,它会显示类似ok发现的语法错误。我使用mozilla,但我非常确定Chrome也支持它。你应该试试看。

FYI:跟踪javascript中任何问题的最佳方法是在google chtome中打开页面,然后按
F12
进行de开发模式。它将向您显示问题。仅供参考:在javascript中跟踪任何问题的最佳方法是在google chtome中打开页面,然后按
F12
进入开发模式。它将向您显示问题。