这样呢document.getElementById("attach0").currentStyle.backgroundColor 

解决方案 »

  1.   

    <input type="text" name="txt" id="txt" style="background-color:#000000" /><input type="button" name="pwd" id="pwd" onclick="alert(document.getElementById('txt').style.backgroundColor);" />必须要是设置背景色,默认虽然是白色的,但是是取不到值的,alert为空
      

  2.   

    写在CSS里的要用currentStyle
    直接写在style里的才能用style
      

  3.   

         用 document.getElementById("attach0").currentStyle.backgroundColor  后,  得到的是 “transparent”,透明色。但实际上是 蓝色 啊?