传承网络文化,缔造精致生活!
联系我们
IT咨询 1356-0066-932 / 147-4811-2363
service@gengge.tech
给我们留言
主页
数据信息
外包服务
数据挖掘
知识库
外包服务
建站/软件服务
项目案例
技术支持
解决方案
企业品牌服务
网络推广
关于我们
联系我们
商务合作
首页
>
知识库
>
jQuery 设置表格隔行变色、隔列变色
jQuery 设置表格隔行变色、隔列变色
12/14/2010 2:48:30 PM
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
>
<html>
<head>
<title>隔行变色、隔列变色</title>
<script type=
"text/javascript"
src=
"jquery.js"
></script>
<script type=
"text/javascript"
>
$(
function
() {
$(
"table:eq(0) tr"
).each(
function
() {
$(
this
).find(
"td"
).each(
function
(i) {
if
(i%2 != 0) {
$(
this
).css(
"background-color"
,
"#CCCCFF"
);
}
else
{
$(
this
).css(
"background-color"
,
"white"
);
}
});
});
$(
"table:eq(1) tr"
).each(
function
(i) {
if
(i%2 != 0) {
$(
this
).css(
"background-color"
,
"white"
);
}
else
{
$(
this
).css(
"background-color"
,
"#CCCCFF"
);
}
});
$(
"table:eq(2)"
).find(
"tr:even"
).css(
"background-color"
,
"white"
).end().find(
"tr:odd"
).css(
"background-color"
,
"#CCCCFF"
);
$(
"table:eq(3) tr"
).find(
"td:even"
).css(
"background-color"
,
"white"
).end().find(
"td:odd"
).css(
"background-color"
,
"#CCCCFF"
);
});
</script>
</head>
<body>
<table width=
"80%"
>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<hr />
<table width=
"80%"
>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<hr />
<table width=
"80%"
>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<hr />
<table width=
"80%"
>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
</body>
</html>
上一遍:
JS input 回车提交
下一遍:
精选27个励志故事