The parentsUntil() is an inbuilt method in jQuery that is used to find all the ancestor elements between two given elements in a DOM tree. The Document Object Model(DOM) is a World Wide Web Consortium standard. This defines for accessing elements in the DOM tree.
Parameters: It accepts a parameter “selector2” which is the last marked parent of the selected element in the tree.
Return Value: It returns all ancestors elements between two given elements.
jQuery code to show the working of parentsUntil() method:
In the above code, all the ancestor elements between “span” and “div” get highlighted with green color.
- jQuery | jQuery.support Property
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jquery Property
- jQuery | has() with Examples
- How to use .on and .hover in jQuery ?
- jQuery | :lt() Selector
- jQuery | before() Method
- jQuery | after() with Examples
- jQuery | die() Method
- jQuery UI | Resizable
- jQuery | on() with Examples
- jQuery UI | Button
- jQuery | :not() Selector
- jQuery | off() Method
- jQuery | val() with Examples
- jQuery | :first Selector
- JQuery | now() method
- jQuery | :even Selector
- jQuery | contains() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.