jQuery offsetParent()Method
Examples
Set the background color of the nearest positioned parent element of the <p> element:
$("button").click(function(){
$("p").offsetParent().css("background-color","red");
});
$("p").offsetParent().css("background-color","red");
});
Try it Yourself »
Definition and Usage
The offsetParent() method returns the first positioned parent element.
Tip:Elements can be positioned via jQuery or the CSS position property (relative, absolute, or fixed).
Syntax
$(selector).offsetParent()
Other Extensions
jQuery Traversing Methods