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: