jquery获取控件绝对位置 怎么获取呢? 
等价于javascript代码:
function getPostion(e)
{  
    var t=e.offsetTop;  
    var l=e.offsetLeft;  
    while(e=e.offsetParent)
    {  
        t+=e.offsetTop;  
        l+=e.offsetLeft;  
    }  
}

解决方案 »

  1.   

    function getPostion(e)
    {  
      alert("x:" + e.style.left + ", y:" + e.style.top);
    }
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <script>
    function getPostion(o) {
    alert(o.offsetLeft + "-" + o.offsetTop);
    alert(o.style.posLeft + "-" + o.style.posLeft);
    alert(o.style.left + "-" + o.style.top);
    }
    </script>
    </head><body>
    <input type="button" onclick="getPostion(this)" value="click"/>
    <input type="button" style="position: absolute; left: 120px; top: 100px;" onclick="getPostion(this)" value="click"/>
    </body>
    </html>
      

  3.   

    jquery:
    <div id="test"/>offsetTop:  $("#test").offset().top;
    offsetLeft:  $("#test").offset().left;上面的方法和楼主的方法等价