Why is it possible to query jQuery('div') like an array?

后端 未结 5 1357
礼貌的吻别
礼貌的吻别 2021-01-05 01:59

I got another question regarding jQuery\'s architecture. $(\'div\') constructs a new jQuery object:

$(\'div\') instanceof jQuery; /         


        
5条回答
  •  无人及你
    2021-01-05 02:34

    jQuery objects are array-like objects.

    An array-like object is an ordinary object that has the same properties that an array does.
    An array like object has a length property set to a positive integer, and properties named 0, 1, ... length − 1 containing the array objects.

提交回复
热议问题