1.获取当前元素到body的距离 function getTL(obj){ var oT=obj.offsetTop; // 获取当前元素到定位父级的上侧距离 var oL=obj.offsetLeft;// 获取当前元素到定位父级的左侧距离 var p=obj.offsetParent