lengthプロパティ

プロパティ length は セット内の要素の数を取得します。

構文

javascript.length;

例

すべての段落を見つけて、その数を数えてみましょう:

html<p>テキスト</p>
<p>テキスト</p>
<p>テキスト</p>
<p>テキスト</p>
<p>テキスト</p>
javascriptlet num = $('p').length;
alert(num);

関連項目

  • メソッド index,
    これはセット内の要素の数を取得します