Object traversal in jQuery. eq (). first (). last (). slice () method _ jquery

Source: Internet
Author: User
This article analyzes the use of the object traversal. eq (). first (). last (). slice () method in jQuery, as well as the differences between them, and the use of jQuery source code. Eq (index): extracts the index element from the set.
First (): returns the first element in the set.
. Last (): the last element in the protection set.
. Slice (start [, end]): returns the elements of the given range in the set.
First () and last () call eq (), eq () through slice () implementation, slice () through
. PushStack () implementation.

Source code

Row 285: The usage is very strange. A "+" is used to convert the I that may be a string into a value.
300 ~ 301: first, use the array method slice () to obtain a subset of the specified range from the current jQuery object,
In the out-of-use method pushStack (), the subset is converted to a jQuery object, and the reference to the current jQuery object is retained through the prevObject attribute.

The above is to learn all the content of. eq (),. first (),. last (),. slice () based on jQuery source code. Have you known them?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.