HTMLSelectElement: length プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

lengthHTMLSelectElement インターフェイスのプロパティで、<select> 要素内の <option> 要素の数を指定します。これは、options コレクション内のノードの数を表します。設定すると、(HTMLOptionsCollection.length) として動作します。

数値です。

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

仕様書

Specification
HTML
# dom-select-length-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
length

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報