Is there any difference between $(".selector").size() and $(".selector").length ?
views:
372answers:
4
+7
A:
No. size() returns length. By using length you only avoid one extra method call.
RoToRa
2010-04-29 14:59:19
+4
A:
Length returns the same thing and is slightly faster according to the jQuery documentation.
Source: http://api.jquery.com/size/
Fabian
2010-04-29 15:01:39
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
2010-04-29 15:01:53
+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
2010-04-29 15:03:02