Easy Tutorial
❮ Jsref Join Jsref Filter ❯

HTML DOM offsetParent Property

Element Object

Example

Get the nearest ancestor element of a div:

var testDiv = document.getElementById("test");
document.getElementById("demo").innerHTML = testDiv.offsetParent;

Definition and Usage

The offsetParent property is a read-only property that retrieves the nearest positioned ancestor element.

Note: The offsetParent is used by the offsetLeft and offsetTop properties.

Tip: When the element's style.display is set to "none", offsetParent returns null.


Browser Support

Property Chrome Edge Firefox Safari Opera
offsetParent Yes Yes Yes Yes Yes

Syntax

element.offsetParent

Technical Details

| Return Value: | A node object representing the nearest ancestor element. | | --- | --- |


Element Object

❮ Jsref Join Jsref Filter ❯