首页 > 代码库 > 下拉菜单
下拉菜单
//菜单下拉
function menu(){
var oNav=document.getElementById(‘top-menu‘);
var aLi=oNav.getElementsByTagName(‘li‘);
for(var m=0;m<aLi.length;m++) {
aLi[m].onmouseover=function(){
clearInterval(this.timer);
this.className="current_page_item";
this.getElementsByTagName(‘ul‘)[0].style.display="block";
}
aLi[m].onmouseout=function(){
var obj=this;
clearInterval(this.timer);
this.timer=setInterval(function(){
obj.className="";
obj.getElementsByTagName(‘ul‘)[0].style.display="none"; },200)
}
}
}
//获取样式
function getByClass(oParent,sClass) {
var aEle=document.getElementsByTagName(‘*‘);
var i=0;
var aResult=[];
for (i=0;i<aEle.length;i++ ) {
if(aEle[i].className==sClass)
{
aResult.push(aEle[i]);
}
}
return aResult;
}