Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get element top in document
function getElementTop(elem) {
  var elemTop = elem.offsetTop;
  elem = elem.offsetParent;
  while (elem != null) {
    elemTop += elem.offsetTop;
    elem = elem.offsetParent;
  }
  return elemTop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.