tags:

views:

372

answers:

4

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

+7  A: 

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

RoToRa
+4  A: 

Length returns the same thing and is slightly faster according to the jQuery documentation.

Source: http://api.jquery.com/size/

Fabian
A: 

.size() is a Method call, which returns the length property. So you either call the method to return the property, or you retrieve the property directly.

The method (.size()) is probably the one you should be using, as it was most likely implemented to abstract away from the possibility of the length property being changed.

Jaymz
+2  A: 

They will both give you the same result but .length is slightly faster.

See http://api.jquery.com/size/

"The .length property is a slightly faster way to get this information."

Jon Dean