绝对X,Y坐标,可以用offset()方法:

12 var X = $('#DivID').offset().top; var Y = $('#DivID').offset().left;

获取相对(父元素)位置:

12 var X = $('#DivID').position().top; var Y = $('#DivID').position().left;

            

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;
             }