编程客栈编程客栈
复制代码 代码如下:
//获取元素的纵坐标
function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
//获取元素的横坐标
function getLeft(e){
var offset=e.offsetLeft;
if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
return offset;
}
bDfxGjxUuwww.cppcns.combDfxGjxUu
本文标题: js获取元素在浏览器中的绝对位置
本文地址: http://www.cppcns.com/wangluo/javascript/58507.html
© 著作权归作者所有
举报
发表评论
0/200