mozilla
Your Search Results

    Element.offsetTop Redirect 2

    The HTMLElement.offsetTop read-only property returns the distance of the current element relative to the top of the offsetParent node.

    Syntax

    topPos = element.offsetTop;
    

    Parameters

    • topPos is the number of pixels from the top of the parent element.

    Example

    var d = document.getElementById("div1");
    var topPos = d.offsetTop;
     
    if (topPos > 10) {
      // object is offset more
      // than 10 pixels from its parent
    }

    Specification

    Specification Status Comment
    CSS Object Model (CSSOM) View Module
    The definition of 'offsetTop' in that specification.
    Working Draft  

    See also

    Document Tags and Contributors

    Contributors to this page: teoli
    Last updated by: teoli,