JQuery method for obtaining all parent and peer elements and child elements (recommended ).
1. Get the parent Element
$("#id").parent()
Obtain parent-level elements
$("#id").parents()
Obtain all of its ancestor Elements
$("#id").closest()
Obtain the most recent ancestor elements
--------------------------------------------------------------------------------
2. Get the same level element
$("#id").next(selector)
Obtain the next sibling element adjacent to the matching element. If a selector is provided, the next sibling element matching the selector is retrieved.
$("#id").nextAll(selector)
Obtain all the compatriot elements behind the matching element. selector filtering is optional.
$("#id").prev(selector)
Obtain the first compatriot element adjacent to the Matching Element (opposite to next)
$("#id").prevAll(selector)
Obtain all compatriot elements before the current Matching Element (opposite to nextAll)
--------------------------------------------------------------------------------
3. obtain child elements
$("#id").children(selector)
Returns the child element of the matching element. You can use the selector to filter the optional parameters.
$("#id").find(selector)
Obtains the descendant of the current element.
Summary
The above is a small series of jQuery methods for getting all the parent and peer elements and child elements. I hope to help you. If you have any questions, please leave a message, the editor will reply to you in time!