<table width="20" border="1">
  <tr>
    <th scope="row">ewr</th>
    <td>wrewrre</td>
  </tr>
  <tr >
    <th scope="row">ewr</th>
    <td>rewr
    <input type="checkbox" id="checkbox" value="checkbox"></td>
  </tr>
  <tr>
    <th scope="row">ewr</th>
    <td>rew</td>
  </tr>
</table>
<input type="button" name="Submit" value="变颜色" onClick="f();">
<script language=javascript>
function f(){
  var s=document.all.checkbox;
  var t=s.parentNode;
  while(t.tagName!='TR'){  t=t.parentNode;}
  t.style.backgroundColor="blue";
}
</script>

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <script language=javascript>function check(obj){ while(obj=obj.parentElement){
    if(obj.tagName=="TD"){
    obj=obj.parentElement;
    break;
    }
    return;
    } if(obj.style.backgroundColor=='')
    obj.style.backgroundColor='red';
    else
    obj.style.backgroundColor='';
    }
    </script>
    </HEAD><BODY>
    <table width="200" border="1" cellspacing="0" style="border-collapse:collapse;" bordercolor="#0099cc">
      <tr >
        <td width="80%">Row1</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="checkbox" id="checkbox" value="checkbox" onclick="check(this)"></td>
      </tr>  <tr >
        <td width="80%">Row1</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="checkbox" id="checkbox" value="checkbox" onclick="check(this)"></td>
      </tr>
        <tr >
        <td width="80%">Row1</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="checkbox" id="checkbox" value="checkbox" onclick="check(this)"></td>
      </tr>
        <tr >
        <td width="80%">Row1</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="checkbox" id="checkbox" value="checkbox" onclick="check(this)"></td>
      </tr>
    </table>
    </BODY>
    </HTML>
    ----------------------------------你要的是这样的吧,做了一段演示一下