用JS做的简单的可折叠的两级树形菜单_javascript技巧
时间:2021-07-01 10:21:17
帮助过:17人阅读
代码如下:
可折叠的两级菜单
window.onload=function(){
varlistUL=document.getElementById("listUL");
varolist=listUL.childNodes;
varoa=0;
for(var i = 0; i < olist.length; i++) {
if(olist[i].tagName=="LI"&&olist[i].getElementsByTagName("ul")[0]){
oa=olist[i];
oa.onclick=change;
}
}
functionchange(){
varos=this.getElementsByTagName("ul")[0];
if(os.className=="myHide")
os.className="myShow";
else
os.className="myHide";
}
}
script>
Home
news
lastest news
all news
sports