{"name":"size","type":"method","title":".size()","deprecated":"1.8","removed":null,"desc":"Return the number of elements in the jQuery object.","categories":["miscellaneous/dom-element-methods","version/1.0","deprecated/deprecated-1.8"],"entries":[{"return":"Integer","signatures":{"added":"1.0"},"examples":{"desc":"Count the divs. Click to add more.","code":"\n$( document.body )\n .click(function() {\n $( this ).append( $( \"
The .size() method is deprecated as of jQuery 1.8. Use the .length property instead.
The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.
Given a simple unordered list on the page:
\n\n<ul>\n <li>foo</li>\n <li>bar</li>\n</ul>\n \n Both .size() and .length identify the number of items:
\nalert( \"Size: \" + $( \"li\" ).size() );\nalert( \"Size: \" + $( \"li\" ).length );\n \n This results in two alerts:
\n\n Size: 2\n
\n\n Size: 2\n
\n "}]}