2016-12-24 40 views
-1

我有以下腳本,我根據用戶輸入單選按鈕計算價格並將其輸出到html部分。該腳本不能正常工作在Internet Explorer中。Java腳本不能在Internet Explorer中工作

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

<form class= "meal-table" id="meal-radio" onsubmit="return false"> 
      <fieldset id="menu"> 
     <input type="radio" id="radio01" name="menu" value="Weight Loss" /> 
     <input type="radio" id="radio02" name="menu" value= "Performance"/> 
      </fieldset> 
    <div> 
     <div class="meal-plan-btn"> 
     <button id="mealbtn" onclick="CalcPrice()">Add To Cart</button> 
    </div> 
</div> 

//這是那裏的價格將被注入

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

你能告訴我完整的代碼嗎,我想你使用的是jQuery吧? –

+0

'該腳本不能在Internet Explorer中正常工作...... ..有兩個問題,它在真正的瀏覽器中工作嗎? (Chrum,Firfox,Edge)...第二,在Internet Explorer中它不工作的方式是什麼?一點都沒有,但在控制檯中有一些錯誤?惡魔是在細節 –

+2

@billynoah - 這很有趣,但最終沒有幫助:p –

回答

0

更改此行

$( 'pricetotal') html的( 「$」 + newprice.toFixed( 2)); ('。pricetotal')。empty()。html(「$」+ newprice.toFixed(2));返回頁首返回頁首返回頁首

相關問題