Back to Content

HTMLSelectElement: name property

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

latest740 B
Original Source

{{ApiRef("HTML DOM")}}

The name property of the {{domxref("HTMLSelectElement")}} interface indicates the name of the {{HTMLElement("select")}} element. It reflects the element's name attribute.

Value

A string representing the element's name.

Example

js
const selectElement = document.querySelector("#planets");
console.log(`Element's name: ${selectElement.name}`);
selectElement.name = "galaxies"; // sets or updates the element's name

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("HTMLSelectElement.value")}}
  • {{domxref("HTMLSelectElement.selectedIndex")}}
  • {{domxref("HTMLSelectElement.options")}}