Back to Content

HTMLButtonElement: name property

files/en-us/web/api/htmlbuttonelement/name/index.md

latest697 B
Original Source

{{ApiRef("HTML DOM")}}

The name property of the {{domxref("HTMLButtonElement")}} interface indicates the name of the {{HTMLElement("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

js
const buttonElement = document.querySelector("#myButton");
console.log(`Element's name: ${buttonElement.name}`);
buttonElement.name = "newName";

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("HTMLButtonElement.value")}}
  • {{domxref("HTMLButtonElement.type")}}