document.getElementById('toptablestyle').style='background:url(../Image/testimg.gif) no-repeat #E9EF82';
=====>
document.getElementById('toptablestyle').style.background='url(../Image/testimg.gif) no-repeat #E9EF82';

解决方案 »

  1.   

    css样式里的padding-left 怎么设置啊
    我这样设置为什么出错?
    <div class="testdiv">
    <h3 id="h3id">
    hello
    </h3>
    </div>document.getElementById('h3id').style.padding-left='10px';  这句出错啊
      

  2.   

    document.getElementById('h3id').style.padding-left='10px';
    ======>
    document.getElementById('h3id').style.paddingLeft='10px';
    在设置style属性时,如style="padding-left:10px"
    在用style.?=?的方式设置时,如果属性里含有"-",一般都将"-"去掉,而将"-"后面的第一个字母大写,即style.paddingLeft="10px"
    再如:style="background-color:#cccccc"
         style.backgroundColor="#cccccc"