鼠标移动到table,使其在鼠标下面的行高亮显示。
来源:互联网 发布:天启四骑士知乎 编辑:程序博客网 时间:2024/06/06 15:38
///////////////////////////////////////////////////////////////////////////////
//
// 功能:这个类使得被附加的表格可以支持行点击高亮
// 参数:
// tbl: 要附加样式的 table.
// selectedRowIndex: 初始高亮的行的索引(从 0 开始). 此参数可省。
// hilightColor: 高亮颜色。可省(默认为绿色)
//
// Author: Neil Chen
// Date: 2005-09-05
//
///////////////////////////////////////////////////////////////////////////////
function TableRowHilighter(tbl, selectedRowIndex, hilightColor) {
this.currentRow = null;
this.hilightColor = hilightColor ? hilightColor : 'green';
if (selectedRowIndex != null
&& selectedRowIndex >= 0
&& selectedRowIndex < tbl.rows.length)
{
this.currentRow = tbl.rows[selectedRowIndex];
//tbl.rows[selectedRowIndex].runtimeStyle.backgroundColor = this.hilightColor;
}
var _this = this;
var _thisTable = tbl;
tbl.attachEvent("onmousemove",table_onMouseMove)
tbl.attachEvent("onmouseout",table_onMouseOut)
function table_onMouseMove() {
var e = event.srcElement;
if (e.tagName == 'TD')
e = e.parentElement;
if (e.tagName != 'TR') return;
// if (e == _this.currentRow) return;
// if (_this.currentRow)
// _this.currentRow.runtimeStyle.backgroundColor = '';
e.runtimeStyle.backgroundColor = _this.hilightColor;
_this.currentRow = e;
}
function table_onMouseOut() {
var e = event.srcElement;
if (e.tagName == 'TD')
e = e.parentElement;
if (e.tagName != 'TR') return;
var count=0;
for(;count<_thisTable.rows.length;count++)
{
if(e==_thisTable.rows[count])
break;
}
if(count%2 ==0)
e.runtimeStyle.backgroundColor = 'EBF3FB';
else
e.runtimeStyle.backgroundColor = '';
}
}
<script language="javascript" type="text/javascript">
// 调用范例,要写在页面的最下面,保证table已经产生,否则document.getElementById('table1')==null
var mytable = document.getElementById('table1');
var count=0;
for(;count<mytable.rows.length;count++)
{
if(count%2 ==0)
mytable.rows[count].runtimeStyle.backgroundColor = 'EBF3FB';
else
mytable.rows[count].runtimeStyle.backgroundColor = '';
}
//调用所编辑的类,使得其响应鼠标事件。
var hilighter1 = new TableRowHilighter(document.getElementById('table1'), 1, '#FFDB77');
</script>
/************************************ANOTHER***************************************
function highlightRow(objRow)
{
// objRow.bgColor = "red";
objRow.runtimeStyle.backgroundColor = "red";
}
function unhighlightRow(objRow)
{
// objRow.bgColor = "";
objRow.runtimeStyle.backgroundColor = "";
}
- 鼠标移动到table,使其在鼠标下面的行高亮显示。
- jquery 移动显示在鼠标下面边框设计
- 鼠标移动在文字上面,让其显示详细信息
- css,js实现在鼠标移动到一个位置在这个位置下面显示一个已经存在的div,这个div的位置随意
- 当鼠标移动到图片使其变大
- js table鼠标移动高亮显示
- eclipse在debug模式下鼠标移动到变量上不显示值的问题
- eclipse在debug模式下鼠标移动到变量上不显示值的问题
- 鼠标移动到某处显示提示信息
- 鼠标移动到指定位置显示内容
- 鼠标移动到热点上,显示详细信息
- 鼠标移动到热点上,显示详细信息
- 鼠标移动到具体位置,显示图片
- JavaScript鼠标移动到div显示图片
- 当鼠标移动到图片上时,跟随鼠标显示放大的图片
- 当鼠标移动到div或者超链接只上时,显示相应的鼠标形状
- 选中表格中相应行的复选框,点击下面的“删除”按钮可以删除相应的行,选中下面的"全选"复选框,则所有行的复选框全部选中,取消则全部取消。 鼠标移动到封面上在旁边显示大图,鼠标移开,大图消失
- 为鼠标移动事件添加新的功能-在状态栏显示鼠标坐标
- 毕业生的10条(转载)
- 《深入Spring2》第五章“AOP及在Spring中的应用”的电子版出来了
- 使用INF安装文件
- Lucene中的范围搜索
- Linux驱动入门
- 鼠标移动到table,使其在鼠标下面的行高亮显示。
- 一个平凡女人一生中做的19件事
- 单词统计小助(c#开源)
- jsp调用jni方法
- 我对编程的看法(原创)
- javascript中的dom应用实例
- 沟通:好措施为什么招致员工抵抗
- ASP.Net中的缓存方案(不仅仅是Cache和Session)(转)
- VC++6.0编译器详解(转载)