Table选中一行

方法一:
 <html>       <head>    <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">    <style>    .EvenOrOddRow{    background-color:   expression((this.sectionRowIndex%2)?'white':'#E0E0E0');    }       </style>   
 <script> 
   var   currentActiveRow; 
   function   changeActiveRow(obj)    { 
  if(currentActiveRow)  
           currentActiveRow.style.backgroundColor="";   
 currentActiveRow=obj; 
   currentActiveRow.style.backgroundColor="Red";    } 
     </script>
    </head>    <body>   
<table   width=100%> 
  <tr   bgcolor=aaaaaa   >    <td>Code</td><td>Name</td>    </tr>   
<tr   class="EvenOrOddRow"   οnclick="changeActiveRow(this);">    <td>001</td><td>zhangsan</td>    </tr>    <tr   class="EvenOrOddRow"   οnclick="changeActiveRow(this);">    <td>001</td><td>zhangsan</td>    </tr>    <tr   class="EvenOrOddRow"   οnclick="changeActiveRow(this);">    <td>001</td><td>zhangsan</td>    </tr>    <tr   class="EvenOrOddRow"   οnclick="changeActiveRow(this);">    <td>001</td><td>zhangsan</td>    </tr>       </body> 
 方法二:
 var   curRow;       //全局行号   
 var   curRowId;   //选中行的记录信息的ID   
var   curColor;   
function   selectRow(tr1){   
if(curRow)    {   
             curRow.bgColor=curColor;   
              curColor=tr1.bgColor;   
             tr1.bgColor="#FFE9B3";   
}else{ 
  curColor=tr1.bgColor;   
 tr1.bgColor="#FFE9B3";    }   
curRow=tr1;    curRowId=tr1.id;   
  调用方法:<tr   οnclick="selectRow(this)">...
table中鼠标移到一条记录上,然后就会自动显示有关这条记录的信息,鼠标移走之后,显示就消失:
其实很简单:用title 属性就可以
<tr  title="11111"  οnclick="selectRow(this);"> 
  <td>001</td><td>zhangsan</td> 
    </tr> 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值