获取元素到body的距离:
<script> function offsetDis(obj) { var l = 0, t = 0; while(obj) { l = l + obj.offsetLeft + obj.clientLeft; t = t + obj.offsetTop + obj.clientTop; obj = obj.offsetParent; } return {left: l, top: t}; } </script>
时间: 2024-10-13 16:53:39