HTML DOM offsetParent Property
Examples
Get the nearest ancestor element of a div:
var testDiv = document.getElementById("test");
document.getElementById("demo").innerHTML = testDiv.offsetParent;
Try it Yourself »
Definition and Usage
offsetParent is a read-only property that gets the nearest positioned ancestor element.
Note:offsetParent is used foroffsetLeftandoffsetTopthe property.
Tip:When the element's style.display is set to "none", offsetParent returns null.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| offsetParent | Yes | Yes | Yes | Yes | Yes |
Syntax
element.offsetParent
Technical Details
| Return Value: | A node object representing the nearest ancestor element. |
|---|
Other Extensions
Element Object