HTML DOM offsetParent property
Example
Get the nearest ancestor element of the div:
var
testDiv
=
document
.
getElementById
(
"
test
"
)
;
document
.
getElementById
(
"
demo
"
)
.
innerHTML
=
testDiv
.
offsetParent
;
Try it »
Definition and Usage
offsetParent is a read-only property that obtains the nearest positioned ancestor element.
Note: offsetParent is used to offsetLeft and offsetTop attribute.
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. |
|---|
Element object