HTML DOM
The name property of the HTMLButtonElement interface indicates the name of the button element or the empty string if the element has no name. It reflects the element's name attribute.
Value
A string representing the element's name.
Example
const buttonElement = document.querySelector("#myButton");
console.log(`Element's name: ${buttonElement.name}`);
buttonElement.name = "newName";
Specifications
Browser compatibility
See also
- HTMLButtonElement.value
- HTMLButtonElement.type
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
