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?