[code=JScript]
navRoot = document.getElementById("menu");var allli = navRoot.getElementsByTagName("li")for (i=0; i<allli.length; i++) {
node = allli[i];
node.onmouseover=function() {
this.className+=" current";
}
node.onmouseout=function() {
this.className=this.className.replace(" current", "");
}
}
}[code]
navRoot = document.getElementById("menu");var allli = navRoot.getElementsByTagName("li")for (i=0; i<allli.length; i++) {
node = allli[i];
node.onmouseover=function() {
this.className+=" current";
}
node.onmouseout=function() {
this.className=this.className.replace(" current", "");
}
}
}[code]
navRoot = document.getElementById("menu");
//获得li这个列表的数组
var allli = navRoot.getElementsByTagName("li")
//循环遍历allli这个数组
for (i=0; i<allli.length; i++) {
node = allli[i];
//当鼠标经过对应的li时,执行this.className的赋值;
node.onmouseover=function() {
this.className+=" current";
}
//当鼠标移出li时,替换this.className的值为空字符串
node.onmouseout=function() {
this.className=this.className.replace(" current", "");
}
}
}