HTMLSelectElement: length property

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

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

Specifications

Browser compatibility

See also