js 元素在文档中的绝对坐标

遍历父元素获得元素在文档中的绝对坐标

function getAbsPoint(e)
{//对象在文档中的绝对坐标
var x = e.offsetLeft,y = e.offsetTop;
while(e = e.offsetParent)
{
x += e.offsetLeft;
y += e.offsetTop;
}
return [x,y];
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注