.length
JQ 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 Example
Core << 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');
});
});
Related Tutorials
jQuery Basic Tutorials - Lesson 2 - jQuery Core & Internals
