js 获取距离顶部的相对高度

getTop (e) { 
        var offset=e.offsetTop; 
        if(e.offsetParent!=null) offset+=this.getTop(e.offsetParent); 
        return offset; 
 },
原文地址:https://www.cnblogs.com/CyLee/p/8678240.html