jQuery size() method vs length attribute

后端 未结 9 2208
天命终不由人
天命终不由人 2020-12-05 22:20

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

9条回答
  •  一整个雨季
    2020-12-05 23:08

    jQuery .size() and .length both return the number of elements in the jQuery object.

    Size() and length in jQuery both returns the number of element in an object but length is faster than the size because length is a property and size is a method and length property does not have the overhead of a function call.

提交回复
热议问题