jquery gets all the parent and sibling elements and child elements of the method

Source: Internet
Author: User

jquery gets all the parent and sibling elements and child elements of the method

1. Gets the parent element $ ("#id"). Parent ()

Gets its parent element

$ ("#id"). Parents ()

Get all of its ancestor elements

$ ("#id"). Closest ()

Gets its nearest ancestor element, followed by

2. Gets the sibling element $ ("#id"). Next (selector)

Gets the next sibling element adjacent to the matching element. If a selector is provided, the next sibling element that matches the selector is retrieved.

$ ("#id"). Nextall (selector)

It is optional to get all the sibling elements that follow the match element, which is filtered by the selector.

$ ("#id"). Prev (selector)

Get the previous sibling element adjacent to the matching element (opposite to next)

$ ("#id"). Prevall (selector)

Gets all the sibling elements preceding the current matching element (as opposed to Nextall)

3. Gets the child element $ ("#id"). Children (selector)

Returns the child elements of the matching element, with optional parameters that can be filtered by the selector.

$ ("#id"). Find (selector)

Gets the descendants of the current element

jquery gets all the parent and sibling elements and child elements of the method

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.