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

A brief discussion on the object traversal .eq().first().last().slice() method in jQuery_jquery

WBOY
Release: 2016-05-16 16:30:26
Original
1545 people have browsed it

eq(index): Extract the element with index index in the collection.
first(): Returns the first element in the collection.
.last(): The last element in the guard collection.
.slice(start[,end]): Returns the elements of the given interval in the collection.
first() and last() call eq(), eq() is implemented through slice(), and slice() is implemented through
.pushStack() implementation.

Related source code

Line 285: The usage is very strange, using a " " to convert i, which may be a string, into a numerical value.
300~301: First use the array method slice() to obtain a subset of the specified range from the current jQuery object,
Use the pushStack() method to convert the subset into a jQuery object, while retaining a reference to the current jQuery object through the attribute prevObject.

The above is the entire content of learning .eq(), .first(), .last(), .slice() based on the jQuery source code. Do you guys understand them?

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!