Understanding how elements relate to each other in the DOM makes it easy to efficiently select elements. We have covered several methods in this lesson including:
.children()to target an element’s child elements.
.siblings()to target elements adjacent to an element.
.parent()to target an element’s parent.
.closest()travels up the DOM tree from the current element to target the closest element with a given selector.
.next()to target the element immediately following the selected element.
.prev()to target the element that is immediately preceding the selected element.
.find()to target descendant elements by some selector, ie- class, id, tag etc.
In addition to these methods, there are even more, including
.nextUntil() and others. To get an idea, check out Mozilla Developer Network reference for jQuery Traversing.