用JS做的简单的可折叠的两级树形菜单_javascript技巧
来源:动视网
责编:小采
时间:2020-11-27 21:13:47
用JS做的简单的可折叠的两级树形菜单_javascript技巧
用JS做的简单的可折叠的两级树形菜单_javascript技巧: 代码如下: 可折叠的两级菜单 body{ background-color:#ffdee0; } #navigation { width:200px; font-family:Arial; } #navigation > ul { list-style-type:none; margin:0px; padding:0px; } #na
导读用JS做的简单的可折叠的两级树形菜单_javascript技巧: 代码如下: 可折叠的两级菜单 body{ background-color:#ffdee0; } #navigation { width:200px; font-family:Arial; } #navigation > ul { list-style-type:none; margin:0px; padding:0px; } #na

代码如下:
可折叠的两级菜单
body{
background-color:#ffdee0;
}
#navigation {
width:200px;
font-family:Arial;
}
#navigation > ul {
list-style-type:none;
margin:0px;
padding:0px;
}
#navigation > ul >li {
border-bottom:1pxsolid #ED9F9F;
}
#navigation > ul >li > a{
display:block;
padding:5px5px 5px 0.5em;
text-decoration:none;
border-left:12pxsolid #711515;
border-right:1pxsolid #711515;
}
#navigation > ul >li > a:link, #navigation >ul >li > a:visited{
background-color:#c11136;
color:#FFFFFF;
}
#navigation > ul >li > a:hover{
background-color:#990020;
color:#ffff00;
}
.txt{
background-color:#c11136;
color:#FFFFFF;
padding:5px5px 5px 0.5em;
text-decoration:none;
border-left:12pxsolid #711515;
border-right:1pxsolid #711515;
} /* 子菜单的CSS样式 */
#navigation ul li ul{
list-style-type:none;
margin:0px;
padding:0px0px 0px 0px;
}
#navigation ul li ulli{
border-top:1pxsolid #ED9F9F;
}
#navigation ul li ulli a{
display:block;
padding:3px3px 3px 0.5em;
text-decoration:none;
border-left:28pxsolid #a71f1f;
border-right:1pxsolid #711515;
}
#navigation ul li ulli a:link, #navigationul li ul lia:visited{
background-color:#e85070;
color:#FFFFFF;
}
#navigation ul li ulli a:hover{
background-color:#c2425d;
color:#ffff00;
}
#navigation ul li ul.myHide{ /* 隐藏子菜单 */
display:none;
}
#navigation ul li ul.myShow{ /* 显示子菜单 */
display:block;
}
-->
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
lastest news all news
weather
lastest news all news
用JS做的简单的可折叠的两级树形菜单_javascript技巧
用JS做的简单的可折叠的两级树形菜单_javascript技巧: 代码如下: 可折叠的两级菜单 body{ background-color:#ffdee0; } #navigation { width:200px; font-family:Arial; } #navigation > ul { list-style-type:none; margin:0px; padding:0px; } #na