style对象中还有很多对象
如:style.backgroundimage

解决方案 »

  1.   

    不同的属性不同,主要注意大小写,
    你上面的属性,可以用下面的方法修改
    <input type="text" name="B" size="8" disabled="true" style="background-color:#C0C0C0">
    <script language=javascript >
    document.getElementById("B").style.backgroundColor="red";
    </script>
      

  2.   

    如果是响应用户操作,用程序动态改变 input的颜色的话,建议使用 runtimeStyle
    这样达到了你要的效果,而且能保护你之前定义的样式,不被程序动态改变
    <input type="text" name="B" size="8" disabled="true" style="background-color:#C0C0C0">
    <script language=javascript >
    alert(B.style.cssText)          //定义的是  "background-color:#C0C0C0"
    B.style.backgroundColor="blue";  //改变了B的style //改变后  "background-color:blue" 
    alert(B.style.cssText)  //下面代码并没有改变B的style,但是文本框的颜色改变了
    B.runtimeStyle.backgroundColor="red";  //B的style还是 "background-color:blue",但是文本框显示已经是红色了
    alert(B.style.cssText)                  
    </script>
      

  3.   

    这样改麻烦。写在css里,用className来改方便
      

  4.   

    方法形式如下:
    <script language=javascript>
    function Changecss()
    {
    var val="BACKGROUND-COLOR:#efc0c0"
    var mel="<input type='text' name='B' size='8' disabled style="+val+">"
    mk.innerHTML=mel
    }
    </script>