<script>
startList = function(){
if(document.all&&document.getElementById){
navRoot = document.getElementById("nav");//获得id为nav对象赋给navRoot,即<ul>...</ul>
for(i=0; i<navRoot.childNodes.length; i++){//遍历navRoot的所有子节点
node = navRoot.childNodes[i]; //将第i个子节点赋给node
if(node.nodeName=="LI"){//如果子节点node的节点名称为LI,即<li>...</li>
node.onmouseover=function(){//则其样式使用前面定义的over样式(这里定义鼠标移上去的样式)
this.className+=" over";
}
node.onmouseout=function(){
this.className=this.className.replace(" over", ""); //定义鼠标移走后的样式
}
}
}
}
}
window.onload=startList; //页面加载时调用startList
</script>
startList = function(){
if(document.all&&document.getElementById){
navRoot = document.getElementById("nav");//获得id为nav对象赋给navRoot,即<ul>...</ul>
for(i=0; i<navRoot.childNodes.length; i++){//遍历navRoot的所有子节点
node = navRoot.childNodes[i]; //将第i个子节点赋给node
if(node.nodeName=="LI"){//如果子节点node的节点名称为LI,即<li>...</li>
node.onmouseover=function(){//则其样式使用前面定义的over样式(这里定义鼠标移上去的样式)
this.className+=" over";
}
node.onmouseout=function(){
this.className=this.className.replace(" over", ""); //定义鼠标移走后的样式
}
}
}
}
}
window.onload=startList; //页面加载时调用startList
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货