offset top jquery code example

Example 1: javascript get element position relative to document

element.getBoundingClientRect().top + document.documentElement.scrollTop

Example 2: 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
}

Example 3: jquery offsetheight

//The offsetHeight property includes the vertical padding and borders in the height calculation, therefore
//the .outerHeight() method would be the jQuery equivalent to offsetheight.
$('.site-header').outerHeight();