请问把这个函数放在循环外边为什么停止运行了呢?
for(var i = 0; i < aLi.length; i++) {
aLi[i].index = i;
aLi[i].onmouseover = function() {
for(var i = 0; i < aLi.length; i++) {
aLi[i].className = "";
}
this.className = "active";
for(var j = 0; j < aDiv.length; j++) {
aDiv[j].className = "hide";
}
aDiv[this.index].className = "show";
}
} for(var i = 0; i < aLi.length; i++) {
aLi[i].index = i;
}
aLi[i].onmouseover = function() {
for(var i = 0; i < aLi.length; i++) {
aLi[i].className = "";
}
this.className = "active";
for(var j = 0; j < aDiv.length; j++) {
aDiv[j].className = "hide";
}
aDiv[this.index].className = "show";
}另外我还想问
为什么原来的程序可以一直检测onclick事件?
请问比如说我把标签移到[1]房产上的时候,整个程序之前之后和现在是怎样运行的?
奥,前两个问题我可能有点懂了,aLi[i].onmouseover = function()这个函数在第一个循环里是定义了这个事件发生时执行函数。
谢谢!!