<script>
lastobj=null;
function current(obj)
{
if(lastobj!=null)
{
lastobj.style.background="";
lastobj.style.color="";
}
obj.style.background="blue";
obj.style.color="white";
lastobj=obj;
}
</script>
<table>
<tr><td onclick=current(this)>baseinfo</td></tr>
<tr><td onclick=current(this)>workflow</td></tr>
<tr><td onclick=current(this)>bbs</td></tr>
</table>

解决方案 »

  1.   

    //这是我的一个JavaScript方法,只要传入当前行的复选框名称就可(传入this)。  function changeBGcolor(ob){
        var vform = document.forms[0];
        var radios = vform[ob];
        for(var a=0;a<radios.length;a++){
          if(radios[a].checked){
            radios[a].parentElement.parentElement.className="trNewBgColor";
          }else{
            radios[a].parentElement.parentElement.className=((a%2==1)?"trOld1":"trOld2");
          }
        }
      }附上样式表:
    <style type="text/css">
    <!--
    .trNewBgColor {
    background-color: #FFEEDD
    }
    .trOld1{
    background-color: #F0F0FF
    }
    .trOld2{
    background-color: #FFFFFF
    }
    -->
    </style>
      

  2.   

    谢谢二位,seabell的方法效果很好,yaray的我试了一下好象没反应,不过还是非常谢谢你。
      

  3.   

    Hello,seabell,你说的方法大体上堪用,但有一个小问题,因为我的表格本身是"灰、白"相间的。当我用你说的方法点击,这这些灰行的背景不能保持----变白了,一阵点击之后就不再是灰白相间的,而是“花白”。这有什么解决办法么?
      

  4.   

    <script>
    lastobj=null;
    function current(obj)
    {
    if(lastobj!=null)
    {
    lastobj.style.background=lastbackground;
    lastobj.style.color=lastcolor;
    }
    lastobj=obj;
    lastbackground=obj.style.background;
    lastcolor=obj.style.color;
    obj.style.background="blue";
    obj.style.color="white";
    }
    </script>
    <table>
    <tr><td onclick=current(this) style="color:blue;background:white">baseinfo</td></tr>
    <tr><td onclick=current(this) style="color:yellow;background:gray">workflow</td></tr>
    <tr><td onclick=current(this) style="color:blue;background:white">bbs</td></tr>
    <tr><td onclick=current(this) style="color:yellow;background:gray">information</td></tr>
    <tr><td onclick=current(this) style="color:blue;background:white">view</td></tr>
    <tr><td onclick=current(this) style="color:yellow;background:gray">memo</td></tr>
    </table>
      

  5.   

    正确的应用:<input type="checkbox" name="M_ID" value="<%=M_ID%>" onclick="changeBGcolor(this.name)">//这是我的一个JavaScript方法,只要传入当前行的复选框名称就可(传入this.name)。
      function changeBGcolor(ob){
        var vform = document.forms[0];
        var radios = vform[ob];
        for(var a=0;a<radios.length;a++){
          if(radios[a].checked){
            radios[a].parentElement.parentElement.className="trNewBgColor";
          }else{
            radios[a].parentElement.parentElement.className=((a%2==1)?"trOld1":"trOld2");
          }
        }
      }附上样式表:
    <style type="text/css">
    <!--
    .trNewBgColor {
    background-color: #FFEEDD
    }
    .trOld1{
    background-color: #F0F0FF
    }
    .trOld2{
    background-color: #FFFFFF
    }
    -->
    </style>