<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").type; document.getElementById("demo").innerHTML = x; } </script>