MDN self-hosted library · e01.org

HTMLSelectElement: length property

HTML DOM

Open notebook · 1 cells web-api-instance-property upstream source

HTML DOM

The length property of the HTMLSelectElement interface specifies the number of option elements in the select element. It represents the number of nodes in the options collection. On setting, it acts as (HTMLOptionsCollection.length).

Value

A number.

Examples

const selectElement = document.getElementById("fruits");
console.log(selectElement.length);

Specifications

Browser compatibility

See also

  • select
  • option
  • HTMLSelectElement.options
  • HTMLSelectElement.selectedOptions
  • HTMLSelectElement.multiple
  • HTMLSelectElement.selectedIndex