function getPosition(ele){
var nTop = ele.offsetTop;
var nLeft = ele.offsetLeft;
while((ele = ele.offsetParent)!=null)
{
nTop += ele.offsetTop;
nLeft += ele.offsetLeft;
}
return {top:nTop,left:nLeft}
}
从dom书中获取某个元素的绝对位置, 跨浏览器IE, Firefox
var nTop = ele.offsetTop;
var nLeft = ele.offsetLeft;
while((ele = ele.offsetParent)!=null)
{
nTop += ele.offsetTop;
nLeft += ele.offsetLeft;
}
return {top:nTop,left:nLeft}
}
从dom书中获取某个元素的绝对位置, 跨浏览器IE, Firefox
No comments:
Post a Comment