源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Table隔行变色的JavaScript代码

  • 时间:2021-04-11 02:40 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Table隔行变色的JavaScript代码
效果演示代码:
[Ctrl+A 全选 注:[url=http://www.1sucai.cn/article/23421.htm]如需引入外部Js需刷新才能执行[/url]]
核心代码:
[u]复制代码[/u] 代码如下:
function showtable(){ var color1 = "rgb(234,240,255)"; var color2 = "rgb(255,255,255)"; var bgColor = "rgb(255,255,193)"; var trs = document.getElementById("datatable").getElementsByTagName("tr"); for (var i=0;i<trs.length-1;i++){ if (i%2==0) { trs[i].style.backgroundColor=color1; trs[i].onmouseover = function(){ this.style.backgroundColor = bgColor; } trs[i].onmouseout = function(){ this.style.backgroundColor = color1; } } else { trs[i].style.backgroundColor=color2; trs[i].onmouseover = function(){ this.style.backgroundColor = bgColor; } trs[i].onmouseout = function(){ this.style.backgroundColor = color2; } } } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部