<html>
<body>
<input type="number" id="myNumber" name="quantity">
<p>点击按钮显示或修改 number 字段的 name 属性值。</p>
<button onclick="display()">显示名称</button>
<button onclick="change()">修改名称</button>
<script>
function display() {
var x = document.getElementById("myNumber").name;
alert(" number 字段名称为: " + x);
}
function change() {
var x = document.getElementById("myNumber").name = "newNumberName";
alert ("名称修改为: " + x);
}
</script>
</body>
</html>