onload = function () {
var current;
var rows = document.getElementById("tbl").getElementsByTagName("tr");
for (var i = 1; i < rows.length; i++) {
rows[i].onclick = function () {
if (current) current.style.backgroundColor = "";
this.style.backgroundColor = "pink";
current = this;
};
rows[i].onmouseover = function () {
// 如果进入的这一行是点过的那一行,就不管
if (current === this) return;
this.style.backgroundColor = "#cccccc";
};
rows[i].onmouseout = function () {
// 如果离开的这一行是点过的那一行,就不管
if (current === this) return;
this.style.backgroundColor = "";
};
}
};
问:为什么onload的current可以得到this值,请用作用域链的相关知识解答