zoukankan
html css js c++ java
变色表格
<
html
>
<
head
>
<
title
>
变色表格
</
title
>
<
script
language
="JavaScript"
>
function
anole (
str_tableid,
//
table id
num_header_offset,
//
表头行数
str_odd_color,
//
奇数行的颜色
str_even_color,
//
偶数行的颜色
str_mover_color,
//
鼠标经过行的颜色
str_onclick_color
//
选中行的颜色
)
{
//
表格ID参数验证
if
(
!
str_tableid)
return
alert (str_tableid
+
"
表格不存在!
"
);
var
obj_tables
=
(document.all
?
document.all[str_tableid] :
document.getElementById(str_tableid));
if
(
!
obj_tables)
return
alert (
"
ID为 (
"
+
str_tableid
+
"
)不存在!
"
);
//
设置个参数的缺省值
var
col_config
=
[];
col_config.header_offset
=
(num_header_offset
?
num_header_offset :
0
);
col_config.odd_color
=
(str_odd_color
?
str_odd_color : '#ffffff');
col_config.even_color
=
(str_even_color
?
str_even_color : '#dbeaf5');
col_config.mover_color
=
(str_mover_color
?
str_mover_color : '#6699cc');
col_config.onclick_color
=
(str_onclick_color
?
str_onclick_color : '#4C7DAB');
//
初始化表格(可能多个表格用同一个ID)
if
(obj_tables.length)
for
(
var
i
=
0
; i
<
obj_tables.length; i
++
)
tt_init_table(obj_tables[i], col_config);
else
tt_init_table(obj_tables, col_config);
}
function
tt_init_table (obj_table, col_config)
{
var
col_lconfig
=
[],
col_trs
=
obj_table.rows;
if
(
!
col_trs)
return
;
for
(
var
i
=
col_config.header_offset; i
<
col_trs.length ; i
++
)
{
//
i 从 表头以下开
始
col_trs[i].config
=
col_config;
col_trs[i].lconfig
=
col_lconfig;
col_trs[i].set_color
=
tt_set_color;
col_trs[i].onmouseover
=
tt_mover;
col_trs[i].onmouseout
=
tt_mout;
col_trs[i].onmousedown
=
tt_onclick;
col_trs[i].order
=
(i
-
col_config.header_offset)
%
2
;
col_trs[i].onmouseout();
}
}
function
tt_set_color(str_color)
{
this
.style.backgroundColor
=
str_color;
}
//
事件操作
function
tt_mover ()
{
if
(
this
.lconfig.clicked
!=
this
)
this
.set_color(
this
.config.mover_color);
}
function
tt_mout ()
{
if
(
this
.lconfig.clicked
!=
this
)
this
.set_color(
this
.order
?
this
.config.odd_color :
this
.config.even_color);
}
function
tt_onclick ()
{
if
(
this
.lconfig.clicked
==
this
)
{
this
.lconfig.clicked
=
null
;
this
.onmouseover();
}
else
{
var
last_clicked
=
this
.lconfig.clicked;
this
.lconfig.clicked
=
this
;
if
(last_clicked) last_clicked.onmouseout();
this
.set_color(
this
.config.onclick_color);
}
}
</
script
>
</
head
>
<
body
>
<
table
id
="demo"
cellpadding
=0
cellspacing
=0
style
="border:1px solid #ccc"
align
="center"
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
<
tr
>
<
td
style
="600px; height:20px;"
></
td
>
</
tr
>
</
table
>
<
script
language
="JavaScript"
>
anole('demo',
0
, '#ffffff', '#f6f6f6', '#f0f0f0', '#cc99ff');
</
script
>
</
body
>
</
html
>
以上JS代码来自互联网,出处忘了
查看全文
相关阅读:
Pentaho
知识地图
分享学习笔记本
2015-7-1 记而随,随而记
web 导出 csv
vs2013 密钥
超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。
如何绘制业务流程图?
总是保存下拉选项的第一个值
mac 修改密码后 频繁输入钥匙串问题修复方法
原文地址:https://www.cnblogs.com/yiki/p/872289.html
最新文章
0518Python基础-内置函数-二分查找
0517Python基础-内置函数
0516Python基础-迭代器-生成器
0515Python基础-带参数的装饰器-多个装饰器
0511Python基础-函数名应用-闭包-装饰器
0510Python基础-动态参数-名称空间
0509Python基础-函数初识
0508Python基础-文件操作
0507Python基础-set-深浅copy
0504Python基础,is == id
热门文章
课后作业
《大道至简》第七八章读后感
课后作业
《大道至简》第六章读后感
课后作业
Ljava.lang.Object;@ba8a1dc
《大道至简》第五章读后感
课后作业加密
动手动脑
《大道至简》第四章读后感
Copyright © 2011-2022 走看看