获得控件的决定位置。

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;

详细出处参考:http://www.jb51.net/article/24348.htm

原文地址:https://www.cnblogs.com/pocter/p/3684523.html