
- jQuery - Home
- jQuery - Roadmap
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
jQuery length Property
The length property in jQuery is used to count the number of elements in the jQuery object. It returns an integer representing the number of matched elements. This property is read-only, meaning you can use it to get the count but not set it.
Syntax
Following is the syntax of jQuery length property −
$(selector).length
Parameters
The "selector" is a string containing a selector expression to match elements against.
Example
In the following example, we are demonstrating the basic usage of the jQuery length property −
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ var paragraphs = $("p"); var count = paragraphs.length; $("div").text("There are " + count + " paragraph(s) on this page."); }); </script> </head> <body> <p>First paragraph.</p> <p>Second paragraph.</p> <p>Third paragraph.</p> <div></div> </body> </html>
After executing the above program, It returns number of paragraph elements in the jQuery object.
jquery_ref_properties.htm
Advertisements