<script>
function cs()
{
  this.className="style1";
}
function cs1()
{
  this.className="style2";
}
</script>
....
<td onmouseover="cs()" onmouseout="cs1()">
....

解决方案 »

  1.   


    <table>
    <tr style="color:red;" onmouseover="this.style.color='blue';">
    <td > 我们</td>
    </tr>
    </table>
    不会啊!
      

  2.   

    this.setAttribute("bgcolor","#111111",0)
    this.style.backgroundColor="#000000"
      

  3.   

    通过td属性改变背景衍射
    this.setAttribute("bgcolor","#111111",0);
    通过td的style属性改变背景衍射
    this.style.backgroundColor="#000000";
      

  4.   

    我认为你给你的控件起一个id吧,直接用
    id.style.color = "red";
    这样是可行的,
    因为id是唯一的,
      

  5.   

    就用id 比较不错,比如
    <table id=otable1>
     <tr id=otr1>
      <td id=otd1_1>..</td>
      <td id=otd1_2>...</td>
     </tr>
    </table>
    如果你想用鼠标点一行就变色,那就只设置TR的id,并在TR里加上脚本onclick="fnFocus(this.id)
    脚本
    <script>
    var oldTR=null;
    function fnFocus(obj){
    if (oldTR != null)
    {oldTR.style.backgroundColor='#FFFFFF';
     oldTR.style.color="#000000";}
    if ( obj)
     {
       obj.style.backgroundColor="#000066";
       obj.style.color="#FFFFFF";
       oldTR=obj;
      }
    }
    </script>
      

  6.   

    记得给分!!!!<table border=1 width=200><tr><td onmouseover="javascript:this.style.backgroundColor='#000000';">dddd</td></tr></table>
      

  7.   

    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <style>
    .s1 {
    background:#FFFFFF;
    color:#FF0000;
    }
    .s2 {
    background:#FF0000;
    color:#FFFFFF;
    }
    </style>
    </HEAD><BODY>
    <TABLE>
    <TR>
    <TD onClick="this.className='s2'">111111</TD>
    <TD style="background:#339900" onClick="this.style.cssText='';this.className='s2'">222222</TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
      

  8.   

    核心问题是楼主没有弄清楚各个背景色设置的优先权问题!!在JS里面调用aTd.style.backgroundColor(而不要用aTd.bgColor或者aTd.className)就不会出现问题!
      

  9.   

    给你一个例子你(们)就明白了!<STYLE TYPE="text/css">
    .red{background-color:red}
    </STYLE>
    <table border=1 width=500>
    <tr>
    <td style="background-color:green" onMouseOver="this.bgColor='red'">this.bgColor='red'</td>
    <td style="background-color:green" onMouseOver="this.className='red'">this.className='red'</td>
    <td style="background-color:green" onMouseOver="this.style.backgroundColor='red'">this.style.backgroundColor='red'</td>
    </tr>
    </table>
      

  10.   

    完全同意jnkc(江南昆虫)的,因为HTML元素决定自身的样式的顺序是先本身的style元素的样再到本身的相应属性(如:bgcolor),最后就是styleSheets的属性值!
      

  11.   

    exceed(风之子)怎么还up啊?该结贴啦!:)