Jquery searches for parent and child elements (Personal Experience) _ jquery

Source: Internet
Author: User
For friends who use js or jquery to find parent and child elements that are confusing, refer to this article because it is a personal summary, it is easier to use js or jquery to find parent and child elements. However, it is always confusing to use it. I have summarized it here. It will be easier to use it in the future.

Here, jquery looks up the method used by the parent element: closest () parents () parent ()

Find () children ()

Js uses the children [] attribute.

Html code

The Code is as follows:






Jquery searches for child elements of a parent Element







Section 1: Find the parent Element



















11 closest () looks up the nearest element (returns a jQuery object with zero or one element)
21 parent () method
31 parent ("selector") Method







Section 2: Search for child elements





















Find the td find () method of table 2
Find the td children () method of table 2
Search for the children [] attribute of js
Tbody2222





Js Code:

The Code is as follows:


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.