function arrow(){
document.arrow.style.left=50%;

为什么改变不了arrow层的left属性?求大侠指教!!<body  onload="arrow();">
<div id="arrow" style="position:absolute;width:150px;height:25px;z-index:4;top:528px;left:10%;">
  <img src="arrow.JPG" width="36" height="16" align="absmiddle">
  </div>

解决方案 »

  1.   

    谢谢啦,加双引号好使了!!但是还得去掉document,加上document就执行不成功!
      

  2.   

    谢谢啦,加双引号好使了!!但是还得去掉document,加上document就执行不成功!
      

  3.   

    document.getElementById("arrow").style.left = "50%"
      

  4.   

    要不不加document 要加的话就document.getElementById("arrow").style.left = "50%";
      

  5.   

    哦。没注意,直接把你的代码拷贝过来改的。
    ie下可以用id直接来引用dom对象,而其他浏览器不能。
    就是在ie下arrow等同于document.getElementById('arrow')
    而其他浏览器必须是document.getElementById('arrow')
      

  6.   

    arrow.style.left="50%";如果直接这么写的话。只能在IE下好使。不信你在火狐下试试?
    好的习惯还是加上document.getElementById("arrow")