Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery size() method vs length attribute

Tags:

jquery

Is there any difference between $(".selector").size() and $(".selector").length ?

like image 779
jantimon Avatar asked Apr 29 '10 14:04

jantimon


People also ask

What does size () method of jQuery returns?

The size() method returns the number of elements matched by the jQuery selector.

What is jQuery size?

The size() is an inbuilt method in jQuery used to find the number of elements matched by the given selector. This method is removed in jQuery 3.0 instead of this length() has been introduced. Syntax: $(selector).size()

What does the length property for a jQuery object return?

The length property is used to count number of the elements of the jQuery object. where selector is the object whose length is to be calculated. Return Values: It returns the length of the selector.

What is $$ in jQuery?

$ sign is just a valid javascript identifier which is used as an alias for jQuery. Prototype, jQuery, and most javascript libraries use the $ as the primary base object (or function). Most of them also have a way to relinquish the $ so that it can be used with another library that uses it.


1 Answers

No. size() returns length. By using length you only avoid one extra method call.

like image 145
RoToRa Avatar answered Oct 07 '22 00:10

RoToRa