刘雷的个人博客

欢迎使用Z-Blog,有问题或意见请到Zblogger.BBS社区反馈,谢谢您的参与使用。

« 除掉FLASH文件的虚线框文档规范文件 »

实用的表格隔行换色代码


提示:您可以先修改部分代码再运行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#ejiaA1 {
    width: 550px;
    border-top: #E3E3E3 1px solid;
    border-left: #E3E3E3 1px solid;
}
#ejiaA1 td,#ejiaA1 th {
    padding: 5px;border-right: #E3E3E3 1px solid;
    border-bottom: #E3E3E3 1px solid;
    font-size:12px;
    height:16px; line-height:16px;
}

#ejiaA1 tr td span {color: #686868}
#ejiaA1 tr td span.st1 {color: #ff0000}
--></style>
<script language="javascript"><!--
function ejiaA1(o,a,b,c,d){
    var t=document.getElementById(o).getElementsByTagName("tr");
    for(var i=0;i<t.length;i++){
        t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
        t[i].onclick=function(){
            if(this.x!="1"){
                this.x="1";//本来打算直接用背景色判断,FF获取到的背景是RGB值,不好判断
                this.style.backgroundColor=d;
            }else{
                this.x="0";
                this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
            }
        }
        t[i].onmouseover=function(){
            if(this.x!="1")this.style.backgroundColor=c;
        }
        t[i].onmouseout=function(){
            if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
        }
    }
}
--></script>
</head>

<body>

<table width="500" border="0" cellspacing="0" cellpadding="0" id="ejiaA1">
  <tr>
    <td colspan="4"><span class="st1">号码:<span>2460</span>  当前页:<span>第1页 共2页 </span>  总次数:<span>66</span>  总时长:<span>284小时36分27秒</span></span></td>
  </tr>
  <tr>
   <th>接入方式</th><th>上网时间</th><th>下网时间</th><th>上网时长</th>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
  <tr>
    <td>宽带接入</td>
    <td>2008-4-23 12:40:18</td>
    <td>2008-4-23 14:50:28</td>
    <td>2小时10分10秒</td>
  </tr>
</table>

  <script language="javascript"><!--
//ejiaA1("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
ejiaA1("ejiaA1","#fff","#F5F5F5","#FFFFCC","#FFFF84");
--></script>

</body>
</html>
  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.7 Laputa Build 70216

Copyright 2007.