HTMLSelectElement: length property
HTML DOM
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