HTMLFormElement: 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.
HTMLFormElement.length
は読み取り専用のプロパティで、 <form>
要素に含まれるコントロールの数を返します。
フォームのコントロールの一覧には elements
プロパティを使用してアクセスすることができます。
これは <form>
要素の子孫である要素、および form
プロパティを使用してフォームのメンバーになった要素の両方が含まれます。
このプロパティで扱われる要素は、 <button>
, <fieldset>
, <input>
(ただし、 "image" 型のものは、歴史的な理由によって除外されます)、<object>
, <output>
, <select>
, <textarea>
です。
値
数値です。
例
js
if (document.getElementById("form1").length > 1) {
// 複数のフォームコントロールがある場合
}
仕様書
Specification |
---|
HTML # dom-form-length-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
length |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.