Element Properties: offsetTop

By: Dusty Arlia
Published on Saturday, August 24, 2013, 12:34 PM
Last Updated on Tuesday, July 14, 2015 at 12:37 AM
Total Updates: 3

All HTML elements have the offsetLeft and offsetTop properties. The values of these properties are determined by the X, Y offset values of the current element and the parent offsetParent node. The X and Y values are calculated from the top-left corner of the current element in relation to the top-left corner of the offsetParent node which contains it. If the offsetParent property of the Element object is null, then the offsetTop and offsetLeft properties are document coordinates.

Here is offsetTop's basic syntax:

var pixels_from_top_of_parent_element = element.offsetTop;

Comments:

Ad:

Ad: