AJAX
Basics
Data
DOM
Effects
Events
Forms
jQuery UI
Plug Ins
Traversing
Just like in javascript, the length()
method returns the length of a string or an array.
In this jQuery example, it will make a list of all found <p> elements and store those results in an array. In this case, the .length property has the count of the array - the number of indexes, not the length a string. This is a property, not a method. There is no need for ().
$("#btnLength1").click(function ()
{
$("#demo1").html("Number of P elements in this doc: " + $("p").length);
});
$("#btnLength2").click(function ()
{
var introLength = $("#intro").html().length;
$("#demo2").html("Length of P#intro: " + introLength);
});