<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
<script  language=javascript>
var selectedTr=null; function c1(obj){
obj.style.background='#FFFFFF'; //把点到的那一行变希望的颜色;
if(selectedTr!=null) selectedTr.style.backgroundColor="";
if(selectedTr==obj) selectedTr=null;//加上此句,以控制点击变白,再点击反灰
else selectedTr=obj;
}</script>
</head> <body>
 单击选中Tr,高亮显示,再单击取消选选中。<input type=button value="选中的是哪一行?" onclick="alert(selectedTr?selectedTr.outerHTML:'没有选中行');">
  <table width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="#cccccc">
    <tr onclick="c1(this);">
      <td >1 </td>
    </tr>
    <tr onclick="c1(this);">
      <td >2 </td>
    </tr>
    <tr onclick="c1(this);">
      <td >3 </td>
    </tr>
  </table>
 </body>
</html>