Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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 脚本在IE中不工作_Javascript_Jquery_Html - Fatal编程技术网

Javascript 脚本在IE中不工作

Javascript 脚本在IE中不工作,javascript,jquery,html,Javascript,Jquery,Html,我有下面的脚本,其中我根据用户输入单选按钮计算价格,并将其输出到html的一部分。脚本在internet explorer中无法正常工作。它适用于FF、Chrome等。脚本应该从单选按钮获取输入,然后根据输入输出不同的价格。它没有在IE中输出价格 var newprice = ""; function CalcPrice(){ // I take the input from the radio buttons here var goals = $("#men

我有下面的脚本,其中我根据用户输入单选按钮计算价格,并将其输出到html的一部分。脚本在internet explorer中无法正常工作。它适用于FF、Chrome等。脚本应该从单选按钮获取输入,然后根据输入输出不同的价格。它没有在IE中输出价格

var newprice = "";        

function CalcPrice(){
    // I take the input from the radio buttons here 
    var goals = $("#menu input[type='radio']:checked").val();

    if (goals=="Weight Loss"){
        newprice="45";
    } else {
        newprice="55";
    }

    $('.pricetotal').html("$"+newprice.toFixed(2));
}
HTML


添加到购物车
//这就是价格注入的地方

          <div class="pricebox" id="priceboxmobile">
            <div class="pricetotal" >
              <span ></span>
            </div></div>

更改此行

 $('.pricetotal').html("$"+newprice.toFixed(2));
致:

似乎有效,有人知道为什么吗?

我想如果你改变

$('.pricetotal').html("$"+newprice.toFixed(2));

会修好的

IE对这类事情很挑剔。
但在这种情况下,它就是您想要的,否则您的
span
将被删除。

或者,完全删除
span

选中此点击F12打开开发人员工具。转到控制台选项卡。是否存在脚本错误?哪个IE版本?如上@EricLaw所述,请澄清您使用的IE版本。一些旧版本可能不支持一些常见的javascript。不幸的是,我无法在IE中测试。由于某些原因,它不允许我在我的计算机上下载IE 9,因为我有windows 10。我收到了一些客户对此的投诉,所以我试图修复它。作为旁注。。。。有没有关于如何在旧的IE版本中进行测试的想法?试试
$('.pricetotal span').html(“$”+newprice.toFixed(2))这就是你想要的,否则你的跨度将被移除。我不能接受我自己的答案,但这就是答案
 $('.pricetotal').empty().html("$"+newprice.toFixed(2));
$('.pricetotal').html("$"+newprice.toFixed(2));
$('.pricetotal span').html("$"+newprice.toFixed(2));