offset javascript code example
Example 1: offsetheight javascript
// The HTMLElement.offsetHeight read-only property returns the height
// of an element, including vertical padding and borders, as an integer.
let intElemOffsetHeight = element.offsetHeight;
Example 2: javascript get element position relative to document
element.getBoundingClientRect().top + document.documentElement.scrollTop
Example 3: offset in js
var d = document.getElementById("div1");
var topPos = d.offsetTop;
if (topPos > 10) {
// object is offset more
// than 10 pixels from its parent
}