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 = '';
};
}
js表格光棒效果3种解决方案,支持动态生成表格
最新推荐文章于 2018-04-27 22:59:15 发布
本文介绍JavaScript中使用事件绑定实现元素状态变化的三种方法,包括直接绑定、设置初始样式绑定及直接样式绑定,详细解释每种方法的工作原理及应用场景。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

159

被折叠的 条评论
为什么被折叠?



