Skip to content

Instantly share code, notes, and snippets.

@mateuszkocz
Created July 19, 2013 16:43
Show Gist options
  • Save mateuszkocz/6040599 to your computer and use it in GitHub Desktop.
Save mateuszkocz/6040599 to your computer and use it in GitHub Desktop.
function getOffset( el ) {
var offsetTop = 0, offsetLeft = 0;
do {
if ( !isNaN( el.offsetTop ) ) {
offsetTop += el.offsetTop;
}
if ( !isNaN( el.offsetLeft ) ) {
offsetLeft += el.offsetLeft;
}
} while( el = el.offsetParent )
return {
top : offsetTop,
left : offsetLeft
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment