Home >Web Front-end >JS Tutorial >jquery finds parent elements and child elements (personal experience summary)_jquery
It is often encountered when using js or jquery to find parent elements and child elements. However, it is always easy to be confused when using it. Here is a summary. I believe it will be much more convenient to use in the future
Here is the method used by jquery to find the parent element upward: closest() parents() parent()
Method used to search down child elements: find() children()
js uses the children[] attribute
html code
Paragraph 1 Find parent element
11closest( ) Finds up to the nearest element (returns a jQuery object of zero or one element) |
21parent() method |
31parent("selector") method |
|
Find table2 The td children() method |
js's children[] attribute to find |
tbody2222 |