jQuery lengthProperty

jQuery 属性jQuery Properties

Example

Output the number of <li> elements:

$("button").click(function(){
    alert($("li").length);
});

Try it Yourself »

Definition and Usage

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


Syntax

$(selector).length


jQuery 属性jQuery Properties

Other Extensions