<html>
<body>
<h3>以下实例演示了如何访问 Number 字段</h3>
<input type="number" id="myNumber" value="2">
<p>点击按钮获取 number 字段的数字。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myNumber").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>