English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery parentsUntil() Method

jQuery Traversal Methods

The parentUntil() method returnsselectorandstopbetween all ancestors.

If both parameters are omitted, this method will return all ancestors, similar toparent()Methods are the same.

Syntax:

$.parentsUntil(stop, selectorExpression)

Example

Return all ancestors between SPAN and BODY:

body (Great Great Grandparent)
div (Great Grandparent)
div (Grandparent)

p (Direct Parent)                 span

Run Code

Parameter Value

ParameterDescription
stop(Optional) A selector expression, element, or jQuery object to indicate where to stop searching for ancestor elements
selectorExpression(Optional) A selector expression, element, or jQuery object to match the element
Note:To return multiple ancestors, separate each expression with a comma

jQuery Traversal Methods