jQuery length propertyThe 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. SyntaxThis property returns the length of the specified selector. The selector is the jQuery object whose length is to be calculated. ExampleIn this example, there are three paragraph elements. We are using the length property to count the number of paragraph elements. Test it NowOutput After the execution of the above code, the output will be - After clicking the button, the output will be - Next TopicjQuery is() method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India