Home  >  Article  >  Web Front-end  >  What does jQuery object[0] mean? _jquery

What does jQuery object[0] mean? _jquery

WBOY
WBOYOriginal
2016-05-16 18:22:151378browse

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")

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn