newRow=iDiv.insertRow();
newCell=newRow.insertCell();
alert(newRow.style.backgroundColor);

解决方案 »

  1.   

    到底是想获得还是想控制啊?下面的代码展示了三种控制的方法。获得当前样式最好通过runtimeStyle。<BODY>
    <table id=t></table>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    newRow=t.insertRow();
    newRow.insertCell().innerText="abcd"
    newRow.insertCell().innerText="1234"
    alert(t.currentStyle.backgroundColor)
    t.bgColor="red"
    alert(t.currentStyle.backgroundColor)
    t.style.backgroundColor="blue";
    alert(t.currentStyle.backgroundColor)
    t.runtimeStyle.backgroundColor="yellow";
    alert(t.currentStyle.backgroundColor)
    t.runtimeStyle.backgroundColor="";
    alert(t.currentStyle.backgroundColor)
    //-->
    </SCRIPT>
    </BODY>