<ul id="ulTop">
<li onmousemove="emotion()" id="li1" onclick="javaScript:alert(this.style.left)">JAVA</li>
              <li>.Net</li>
              <li>VB</li>
               <li>C语言</li>
               <li onclick="javaScript:alert(this.style.margin-left)">C++</li>
</ul>
为什么弹出来的都是空值。。
要加什么属性吗

解决方案 »

  1.   

    style.marginLeft
    是这个吧 。
      

  2.   

    非也非也..
    top值: document.getElementById('obj').offsetTop+document.body.scrollTop
    left值:document.getElementById('obj').offsetLeft;
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
        <script src="jquery-1.4.4.js" type="text/javascript"></script>
    </head>
    <body>
        <ul id="ulTop">
            <li onmousemove="emotion()" id="li1" onclick="javaScript:alert($(this).css('left'))">JAVA</li>
            <li>.Net</li>
            <li>VB</li>
            <li>C语言</li>
            <li onclick="javaScript:alert($(this).css('marginLeft'))">C++</li>
        </ul>
    </body>
    </html>