Today I need to find out that how many elements were selected by jQuery selector. For your information, jQuery selector returns a jQuery object that has .lenght property. So the easiest way to get the length is using the .lenght property.
jQuery also provides .size() method, which also does the same thing as the .lenght property. But the .lenght property is preferred because it does not have the overhead of a function call.
var iCount = $('.cssClass').length;If you want to know how many div elements present on the page then,
var eCount = $('div').length;See result below.
jQuery also provides .size() method, which also does the same thing as the .lenght property. But the .lenght property is preferred because it does not have the overhead of a function call.
See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.
No comments:
Post a Comment