标签:return fun product element alt == AC scrolltop actual
使用:getElementViewTop($(".product .tab a")[0]) //注意一定要加[0]
//获取视口高度
function getElementViewTop(element) {
var actualTop = element.offsetTop;
var current = element.offsetParent;
while (current !== null) {
actualTop += current.offsetTop;
current = current.offsetParent;
}
if (document.compatMode == "BackCompat") {
var elementScrollTop = document.body.scrollTop;
} else {
var elementScrollTop = document.documentElement.scrollTop;
}
return actualTop - elementScrollTop;
}
标签:return fun product element alt == AC scrolltop actual
原文地址:https://www.cnblogs.com/amanda-man/p/9204547.html