html table单双行颜色间隔(转载)
直接上代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb3212">
<title>单双行显示不同颜色</title>
<script type="text/javascript">
window.onload = function color(){
var table = document.getElementById("person");
var rows = table.getElementsByTagName("tr");
for(var i=0;i<rows.length;i++){
if (i%2==0){
rows[i].style.backgroundColor = "#EAF2D3"
}else{
rows[i].style.backgroundColor = "White";
}
}
}
</script>
<style type = "text/css">
#person
{
border-style:1px solid;
border-color:blue;
font-weight:bold;
font-family:楷体,Arial,Helvetica, sans-serif;
border-collapse:collapse;
margin:auto;
}
#person th
{
border:1px solid;
padding:3px 7px 2px 7px
background-color:#A7C942
color:#ffffff
text-align:center;
}
#person td
{
border-style:solid;
border-width:1px;
text-align:center;
}
</style>
</head>
<body>
<table id="person" align="center" width = "90%" height="200">
<tr>
<th>姓名</th>
<th>性别</th>
<th>电话</th>
<th>爱好</th>
</tr>
<tr>
<td>zhangsan</td>
<td>male</td>
<td>123456</td>
<td>swimming</td>
</tr>
<tr>
<td>zhangsan</td>
<td>male</td>
<td>123456</td>
<td>swimming</td>
</tr>
<tr>
<td>zhangsan</td>
<td>male</td>
<td>123456</td>
<td>swimming</td>
</tr>
</table>
</body>
</html>
html table单双行颜色间隔(转载)的更多相关文章
- js改变,设置table单双行颜色,jquery改变,设置table单双行颜色
1.js实现单双行以不同颜色显示 $(document).ready(function () { var color = "#ffeab3"; $("#GvList tr ...
- table 控制单双行颜色以及鼠标hover颜色 table光棒
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- repeater单双行颜色不同,gridview repeater DataList 鼠标经过改变背景颜色
1.gridview 双击GridView的OnRowDataBound事件: 在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示: protected void ...
- Js实现table单双行交替色
依稀记得,当初我刚学编程的时候还学过怎么实现表格单双行交替色,现如今早已记不清当时的实现思路,这两天突然想起,没事就自己写了一小段代码,也不知道是否是当年的思路,不过不用纠结这个问题.:) 代码很简单 ...
- 奇偶选择器:使用odd和even属性实现表格单双行颜色相间和不同
一.奇偶选择器 表格在呈现数据的时候我们为了方便观看,而隔行显示不同的颜色,虽然可以用用类选择器 class实现这种效果,但是未免太过麻烦,为了更加简便地表现这种特殊的效果我们需要用到一种特殊的选择器 ...
- js控制表格单双行颜色交替显示
<script language="JavaScript"> window.onload = function() { var Table=document.getEl ...
- JS实战 · 表格行颜色间隔显示,并在鼠标指定行上高亮显示
思路: 1.获取所有行对象,将需要间隔颜色显示的行对象进行动态的className属性指定: 前提是:先定义好类选择器,就是说给行对象赋予name. 2.高亮用到两个事件:onmouseov ...
- css单双行样式
#random_box li:nth-child(odd) {//双行 background: #fff5c4; } #random_box li:nth-child(even) {//单行 back ...
- PB中datewindow单双行显示不同颜色
调出datewindow,找到detail中的列,右击properties,左侧Background中的color属性添加 IF(MOD(GETROW(),2)=0,RGB( 255, 250, 20 ...
随机推荐
- 套接字I/O模型-完成端口IOCP
“完成端口”模型是迄今为止最为复杂的一种I/O模型.然而,假若一个应用程序同时需要管理为数众多的套接字,那么采用这种模型,往往可以达到最佳的系统性能!但不幸的是,该模型只适用于Windows NT和W ...
- 代码里面执行bat
public static void executeBat(String path) { try { File file = new File(path); ...
- Object-c 语言
字符串操作: http://www.myexception.cn/mobile/455287.html 1,判断两字符串是否相同 NSString *str1 = @"hello pepe& ...
- 在jQuery EasyUI中实现对DataGrid进行编辑
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- Git服务器搭建及SSH无密码登录设置
在Git服务器中建立一个git帐号,用于多人使用. adduser git输入此命令后,会在/home/下建立一个git文件 /home/git 下建立.ssh目录(注意,是.ssh..有个点!) c ...
- python compile
compile(source, filename, mode[, flags[, dont_inherit]]) 参数source:字符串或者AST(Abstract Syntax Trees)对象. ...
- sql2008读取excel
环境:win7(64位)+sql2008 sql语句: --启用Ad Hoc Distributed Queries: reconfigure reconfigure --使用完成后,关闭Ad Hoc ...
- PXE-无人值守安装
[root@rhel6 ~]# cp /root/ks.cfg /var/ftp/ks.cfg [root@rhel6 ~]# cat ks.cfg #platform=x86, AMD64, 或 I ...
- sql访注入
http://www.dewen.org/q/6154/java%E7%A8%8B%E5%BA%8F%E9%98%B2%E6%AD%A2sql%E6%B3%A8%E5%85%A5%E7%9A%84%E ...
- sql在添加新列时同时指定default约束名称
alter table tab_testadd col_test NOT NULL CONSTRAINT DFtab_test_col_test DEFAULT 1 引用:http://www.uzz ...