Home > Article > Web Front-end > What does jQuery object[0] mean? _jquery
Code:
var s=$("div");
alert(s.length);
alert(s[0]);
jQuery objects have a 0 index by default ,
s is a jQuery object
s[0] is a Dom element. You can use all the attributes and methods of dom.
can determine how many Dom element objects are included in total based on the length attribute.
To get the object, use: s[0], s[1], s[2]...
#id matches an element based on the given ID. $("#id1")
element matches all elements based on the given element name $("div")