JQuery traverses the next step based on the current element _ jquery

Source: Internet
Author: User
The element is selected using the jQuery method. How can I next traverse the selected elements? The following is a good example. If we have selected a group of elements through the jQuery method, how can we next traverse these selected elements?

For example

$ ('Li: eq (1 )')

The second li element in the following code is selected.

The Code is as follows:



  • Link

  • Selected link

  • Link

  • Link



Based on the selected element, we can further traverse other elements.

Next Element

$ ('Li: eq (1) '). next ()

Previous Element

$ ('Li: eq (1) '). prev ()

Parent Element

$ ('Li: eq (1) '). parent ()

All sibling Elements

$ ('Li: eq (1) '). parent (). children ()

All subsequent sibling Elements

$ ('Li: eq (1) '). nextAll ()

All previous brothers

$ ('Li: eq (1) '). prevAll ()

You can use the end () method to cancel all the preceding traversal methods.

Of course, you can also use parameters, such

$ ('Li: eq (1) '). parent (). children (': la ')
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.