jQuery .parentsUntil()
Learn all about the jQuery function .parentsUntil().
Given a selector expression that represents a set of DOM elements, the .parentsUntil()
method traverses through the ancestors of these elements until it reaches an element matched by the selector passed in the method’s argument. The resulting jQuery object contains all of the ancestors up to but not including the one matched by the .parentsUntil()
selector.
If the selector is not matched or is not supplied, all ancestors will be selected; in these cases it selects the same elements as the .parents()
method does when no selector is provided.
As of jQuery 1.6, A DOM node or jQuery object, instead of a selector, may be used for the first .parentsUntil() argument.
The method optionally accepts a selector expression for its second argument. If this argument is supplied, the elements will be filtered by testing whether they match it.