Last active
August 2, 2017 06:52
-
-
Save jovey-zheng/56718e1318b882ec158a5cbeecd033a7 to your computer and use it in GitHub Desktop.
Get element top in document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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