.offsetParent()Returns: jQuery
Description: Get the closest ancestor element that is positioned.
- 
version added: 1.2.6.offsetParent()- This method does not accept any arguments.
 
Given a jQuery object that represents a set of DOM elements, the .offsetParent() method allows us to search through the ancestors of these elements in the DOM tree and construct a new jQuery object wrapped around the closest positioned ancestor. An element is said to be positioned if it has a CSS position attribute of relative, absolute, or fixed. This information is useful for calculating offsets for performing animations and placing objects on the page.
Consider a page with a basic nested list on it, with a positioned element:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 
 | 
If we begin at item A, we can find its positioned ancestor:
| 1 | 
 | 
This will change the color of list item II, which is positioned.
Example:
Find the offsetParent of item "A."
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 
 |