当前位置: 首页 > 图文教程 > 网络编程 > Javascript > js兼容标准的表格变色效果

Javascript
ext实现完整的登录代码
ext form 表单提交数据的方法小结
收藏,对比功能的JS部分实现代码
js可突破windows弹退效果代码
js获取div高度的代码
JS支持带x身份证号码验证函数
javascript的indexOf忽略大小写的方法
js活用事件触发对象动作
Javascript访问html页面的控件的方法详细分析
jQuery formValidator表单验证插件开源了 含API帮助、源码、示例
js仿淘宝的拼音检索特效代码
鼠标放上去触发一个javascript提示框效果代码
FF下zoom的替代方案 单位em
json编写简单一例
js取得2008奥运金牌排名
js常用函数2008-8-16整理
一些不错的js函数ajax
javascript:void(0)的真正含义实例分析
解决AJAX中跨域访问出现''没有权限''的错误
比较详细的XMLDOM对象方法详解

Javascript 中的 js兼容标准的表格变色效果


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 213 ::
收藏到网摘: n/a

符合标准的表格变色的js代码 <!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" />
<style type="text/css">
* { margin:0; padding:0; font-size:14px }
body { text-align:center;}
#btn { list-style:none inside; width:210px; margin:10px auto; clear:both; }
#btn li { float:left; width:100px; line-height:20px }
#btn li a{ display:block; text-decoration:none; color:#333333}
#gray { background:#f5f5f5; cursor: pointer }
#green { background:#D7ECDE; cursor:pointer }
table { border-collapse:collapse; width:70%; margin:10px auto }
td { line-height:100%; height:24px; line-height:24px; padding:0 4px }
td a { text-decoration:none; color:#333; display:block; }
#tab_gray td { border:1px solid #B9B9B9; background: #F2F2F2; }
#tab_green td { border:1px solid #95CCA7; background:#EBF5EE; }
#tab_gray td:hover, #tab_green td:hover { background:#fff; }
</style>
</head>
<body>
<ul id="btn">
<li id="gray"><a href="javascript:void()" onclick="gray()">gray</a></li>
<li id="green"><a href="javascript:void()" onclick="green()">green</a></li>
</ul>
<table id="tab_gray">
<tr>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
</table>
<script language="javascript">
function green(){
document.getElementById("tab_gray").id="tab_green";
}
function gray(){
document.getElementById("tab_green").id="tab_gray";
}
</script>
</body>
</html>