.lengthS2C Home « Core & Internals « .length
Elements count.
Description
The .length property holds the number of elements in the jQuery object.
Syntax
| Signature | Description |
|---|---|
.length | The number of elements in the jQuery object. |
Parameters
None.
Return
A Number object.
.length ExampleTop
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');
});
});