HTMLElement.offsetParent

The HTMLElement.offsetParent read-only property returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. If the element is non-positioned, the nearest td, th, table or the body is returned.

offsetParent returns null when the element has style.display set to none. offsetParent is useful because offsetTop and offsetLeft are relative to its padding edge.

Syntax

parentObj = element.offsetParent;

parentObj is an object reference to the element in which the current element is offset.