鼠标移动变色的问题
这是我自己的代码语言实现鼠标变色功能,期间也参考了正解和他人的代码都没有看到变色效果,是代码问题吗?还是浏览器问题?
function onload() {
var tbody = document.getElementById('table').lastChild;
var trlist = tbody.getElementsByTagName('tr');
for (var i = 1; i < trlist.length; i++) {
trlist[i].onmouseover = function () {
this.style.backgroundColor = "#f2f2f2";
}
trlist[i].onmouseout = function () {
this.style.backgroundColor = "#fff";
}
}
}