【发布时间】:2012-09-07 13:45:58
【问题描述】:
我在 HTML 网页中使用数字。问题是我想要没有小数的数字。
function copyText() {
var mynumber = document.getElementById("field1").value;
alert(mynumber);
var mytest = parseInt(mynumber);
}
Field1: <input type="number" id="field1" value="123.124" /><br /><br />
<button onclick="copyText()">Check Number</button>
<p>A function is triggered when the button is clicked. The function copies the text in Field1 to Field2.</p>
【问题讨论】:
-
任您选择:
Math.round、Math.ceil、Math.floor。 -
当您说“仍然无法正常工作”时,告诉您得到的信息会更有用 - 错误或磨损值或什么?
-
你的第一个问题是关于浮点数与整数的乘法,现在是关于解析字符串,使得其中一些答案无关紧要。
标签: javascript