jQuery length Property

Last Updated:

jQuery length Property

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

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery length Property</h1> <p>Alert the no of Fruits</p> <button>Click Me</button> <ul> <li>Apple</li> <li>Banana</li> <li>Cheery</li> </ul> <script> $(document).ready(function(){ $("button").click(function(){ alert($("ul li").length); }); }); </script> </body> </html>

Syntax

$(selector).length;

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
lengthYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author