首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js报表光棒效果3种解决方案,支持动态生成表格

2012-11-06 
js表格光棒效果3种解决方案,支持动态生成表格var table document.getElementById(table_id)var rows

js表格光棒效果3种解决方案,支持动态生成表格

var table = document.getElementById(table_id);var rows = table.getElementsByTagName("tr");// 第一种方法for (i = 1; i < rows.length; i++) {// 0 is start     var srcBgColor = null;     rows[i].onmouseover = function() { srcBgColor = this.style.backgroundColor; this.style.backgroundColor = 'red';       };     rows[i].onmouseout = function() { this.style.backgroundColor = srcBgColor;      };}// 第二种方法for (i = 1; i < rows.length; i++) {// 0 is start     var srcBgColor = rows[i].style.backgroundColor;     rows[i].onmouseover = function() { this.style.backgroundColor = 'red';       };     rows[i].onmouseout = function() { this.style.backgroundColor = srcBgColor;      };}// 第三种方法for (i = 1; i < rows.length; i++) {// 0 is start     rows[i].onmouseover = function() { this.style.backgroundColor = 'red';       };     rows[i].onmouseout = function() { this.style.backgroundColor = '';      };}

热点排行