// 获取左边
function getElementLeft(element){
var actualLeft = element.offsetLeft;
var current = element.offsetParent;
while (current !== null){
actualLeft += current.offsetLeft;
current = current.offsetParent;
}
return actualLeft;
}
// 获取顶部
function getElementTop(element){
var actualTop = element.offsetTop;
var current = element.offsetParent;
while (current !== null){
actualTop += current.offsetTop;
current = current.offsetParent;
}
return actualTop;
}
标签:actualLeft,浏览器,offsetParent,dom,element,current,actualTop,var,js
From: https://www.cnblogs.com/sqmw/p/17284083.html