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 -
Next TopicjQuery is() method
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week