读书人

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

发布时间: 2012-11-06 14:07:00 作者: rapoo

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 = '';      };}

读书人网 >JavaScript

热点推荐