jQuery length property
The length property in jQuery is used to count the number of elements in the jQuery object.
The size() function also returns the number of elements in the jQuery object. But it is preferred to use the length property over the size() function because the length property avoids an extra function call, so it is quicker than the size() function. We can use the length property as an alternative of the size() function because the size() function is deprecated in jQuery version 1.8, and it is completely removed in version 3.0.
This property returns the length of the specified selector. The selector is the jQuery object whose length is to be calculated.
In this example, there are three paragraph elements. We are using the length property to count the number of paragraph elements.Test it Now
After the execution of the above code, the output will be -
After clicking the button, the output will be -