既然你說的數字,它只是把價值空間之前。
HTML:
<tr>
<td class="normal">
<div align="right">SGST @ 9% :</div>
</td>
<td nowrap class="normal">
<div align="right">
<div id="divCheckbox1" style="display: none;">
<input step=0.001 id="first" value="1 000">
<input step=0.001 id="second" value="2 .0">
</div>
<button type="button" id="modal1" onclick="divideBy()"></button>
<span id="answer"></span>
<span style="display:inline-block; width: 5;"></span>
</td>
</td>
</tr>
<tr>
<td class="normal">
<div align="right">CGST @ 9% :</div>
</td>
<td nowrap class="normal">
<div align="right">
<div id="divCheckbox" style="display: none;">
<input step=0.001 id="first1" value="1 000">
<input step=0.001 id="second1" value="2 .0">
</div>
<button type="button" id="modal" onclick="divideBy()"></button>
<span id=answer1></span>
<span style="display:inline-block; width: 5;"></span>
</td>
</td>
</tr>
JS:
function divideBy() {
var w = document.getElementById("first").value ;
var x = document.getElementById("second").value;
var y = w.replace(" ","")/x.replace(" ","");
y = y.toFixed(2);
var z = y;
document.getElementById("answer").innerHTML = z;
var a = document.getElementById("first1").value;
var b = document.getElementById("second1").value;
var c = a.replace(" ","")/b.replace(" ","");
var d = c;
d = d.toFixed(2);
var e = d
document.getElementById("answer1").innerHTML = e;
document.getElementById('modal').style.visibility = 'hidden';
document.getElementById('modal1').style.visibility = 'hidden';
}
歡迎計算器!你能否澄清一下**你的問題是什麼?你期望會發生什麼,而發生什麼呢?爲了讓我們更好地爲您提供幫助,請讓我們知道更多關於**代碼的信息。如果您能讓我們知道您迄今爲止已經嘗試解決您的問題,也會有所幫助。有關詳細信息,請參閱有關[**如何提出良好問題**](http://stackoverflow.com/help/how-to-ask)的幫助文章,並參加該網站的[**遊覽**](http://stackoverflow.com/tour):) –
所以問題是與 腳本心不是計算1 000作爲1000,其值爲1. –
,因爲'value = 1 000'意味着屬性值= 1和一些(被忽略)屬性被稱爲'000' ... HTML非常容忍「垃圾」屬性 –