As you know the terms parent, child, and sibling are used to describe the relationships. Parent nodes have children and children on the same level are called siblings. The jQuery parent() method is used to get the ancestors of each element in the DOM tree through the current set of matched elements.
This method optionally accepts a selector expression of same type which we pass to the $() function. The elements will be filtered by testing whether they match it or not if the selector is supplied.
Example