Skip to content

Instantly share code, notes, and snippets.

@leodutra
Created May 5, 2012 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leodutra/2599381 to your computer and use it in GitHub Desktop.
Save leodutra/2599381 to your computer and use it in GitHub Desktop.
Gets HTMLElement Global Offset Left/Top (JS)
function getGlobalOffset(el) {
var x = 0, y = 0
while (el) {
x += el.offsetLeft
y += el.offsetTop
el = el.offsetParent
}
return { left: x, top: y }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment