.lengthS2C Home « Core & Internals « .length

Elements count.

Description

The .length property holds the number of elements in the jQuery object.

Syntax


Signature Description
.lengthThe number of elements in the jQuery object.

Parameters

None.

Return

A Number object.

.length Examplego to top of page Top

The number of elements in the jQuery object.


$(function(){
  $('#btn2').on('click', function() { 
    var noOfElements = $('p').length; 
    alert('There are ' + noOfElements + ' p nodes in the DOM'); 
  });
}); 

Press the button below to action the above code:


go to home page Homepage go to top of page Top