Alex Rivera | Logout

jQuery size() method vs length attribute

Asked 2010-04-29T14:57:06.090
59

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

Edit
Report

1 Answer

3

.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.

answered 2010-04-29T15:01:53.660

Your Answer