Home > Web Front-end > JS Tutorial > body text

What does jQuery object[0] mean? _jquery

WBOY
Release: 2016-05-16 18:22:15
Original
1345 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!