<!DOCTYPE html>charset="utf-8"W3Cschool教程(w3cschool.cn)type="number" id="myNumber" name="quantity"点击按钮显示 number 字段的 name 属性名称。onclick="myFunction()"点我id="demo"function myFunction() {var x = document.getElementById("myNumber").name;document.getElementById("demo").innerHTML = x;}