JS and JQ get parent, brother, child node

Source: Internet
Author: User

1,JS Get node:

Parent: ParentNode Gets the parent node of the known node.

Sub: childNodes; Get all child nodes children get all child nodes FirstChild get the first child node LastChild get the last child node brother: PreviousSibling Get the previous node of a known node nextSibling get    The next node of the known node 2,JQ gets the node: Parent: $ (' # '). Parent () Gets the parents at the previous level.    $ (' #items '). Parents ('. Parent1 ') gets which level of parent node is available. $ (' li:parent ') Sub: $ (' #test span ') using the filter criteria $ (' #test '). Find () uses find () $ (' #test '). Children (") using the Children () function Brother: $ (' # Test '). Siblings () returns the sibling node, not before or after $ (' #test '). Prevall () returns all previous sibling nodes $ (' #test '). Prev () returns the previous sibling node, not all sibling nodes $ (' #test ') . Next () returns the next sibling node, not all of the sibling nodes $ (' #test '). Nextall () returns all subsequent sibling nodes

JS and JQ get parent, brother, child node

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.