标题: [Js] 表格以及列表隔行换色的js效果
发表于 2007-7-3 20:40 第1楼由 zhufei 发起
zhufei
管理员
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
UID 2981
精华 4
积分 197
帖子 1667
金钱 2475 A币
阅读权限 200
注册 1982-4-26
状态 离线
勤劳建设奖  
表格以及列表隔行换色的js效果




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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" media="screen">
<!-- /* PR-CSS */
table {border-collapse:collapse;border:solid #999;border-width:1px 0 0 1px;}
table td {border:solid #999;border-width:0 1px 1px 0;}
.t1 {background-color:#fff;}/* 第一行的背景色 */
.t2 {background-color:#eee;}/* 第二行的背景色 */
.t3 {background-color:#ccc;}/* 鼠标经过时的背景色 */
-->
</style>
</head>
<body>
<ul><li>11111111</li>
<li>222222222</li>
<li>3333333</li>
<li>444444444</li>
</ul>
<script type="text/javascript">
<!--
var Ptr=document.getElementsByTagName("li");
function $() {
    for (i=1;i<Ptr.length+1;i++) {
    Ptr[i-1].className = (i%2>0)?"t1":"t2";
    }
}
window.onload=$;
for(var i=0;i<Ptr.length;i++) {
    Ptr[i].onmouseover=function(){
    this.tmpClass=this.className;
    this.className = "t3";
   
    };
    Ptr[i].onmouseout=function(){
    this.className=this.tmpClass;
    };
}
//-->
</script>
</body>
</html>



顶部


当前时区 GMT+8, 现在时间是 2008-9-7 14:57