The length property

The length property gets the number of elements in the set.

Syntax

javascript.length;

Example

Let's find all the paragraphs and count their number:

html<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
javascriptlet num = $('p').length;
alert(num);

See also

  • method index,
    which gets the number of elements in a set