我意思不是用 test.offsetLeft+":"+test.offsetTop
这样的方式取是问为什么我明明定义过了,却取不到值而如果我把定义写在 <p id="t2" style="left:10;top:10">你知道我的位置么</p>
就可以了这是为什么?

解决方案 »

  1.   

    <div id="t1" style="left:100px">
    <p id="t2">你知道我的位置么</p>
    </div>
      

  2.   

    谢谢楼上回复obj.currentStyle.left
    可以取到 "26px"但我需要的是 26这个数字obj.currentStyle.pixelLeft
    不可用为什么? currentStyle和style有啥区别?怎么取得26呢?
      

  3.   

    rczjp(开着宝马做爱) 
    请看我1楼的说明
      

  4.   

    parseInt(obj.currentStyle.left)
    这个似乎就是这么规定的,写在元素里时用style,写在样式表中的用currentStyle(IE5+)
      

  5.   

    test.style.left.substring(0,test.style.left.length-2)
      

  6.   

    test.currentStyle.left.substring(0,test.currentStyle.left.length-2)