Select length attribute

Definition and Usage

length Property returns the number of <option> elements in the dropdown list.

See also:

HTML Reference Manual:HTML <select>-Tag

Example

Find the number of <option> elements in the dropdown list:

var x = document.getElementById("mySelect").length;

Versuchen Sie es selbst

Syntax

selectObject.length

Technische Details

Rückgabewert: Zahl, die die Anzahl der im Dropdown-Menü gefundenen <option>-Elemente angibt.

Browserkompatibilität

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützung Unterstützung Unterstützung Unterstützung Unterstützung