<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>多選項切換導航菜單</title>
</head>
<style type="text/css">
#dNavBar{
background-color:#ffffff;
}
#dNavBar li{
list-style-type:none;
float:left;
width:84px;
height:28px;
line-height:28px;
font-size:12px;
color:#FFFFFF;
border:1px solid #ffffff;
background:#86C2FF;
text-align:center;
display:block;
cursor:pointer;
}
#subMenu{
background:#99cc66;
width:500px;
border-left:1px solid #ffffff;
border-right:1px solid #ffffff;
height:29px;
line-height:29px;
color:#FFFFFF;
font-size:12px;
padding-left:10px;
}
body {
margin: 0px;
}
a:link,a:visited {
color: #FFFFFF;
text-decoration: none;
}
a:hover{
color: #FFFFFF;
text-decoration: none;
}
</style>
<script language="javascript">
function ShowMenu()
{
var barCTT=document.getElementByIdx_x("dNavBar")
var liArr=barCTT.getElementsByTagName_r("li")
var links=new Array()
links[0]="<a href='#'>當前位置:首頁"
links[1]="<a href='#'>項目一</a> | <a href='#'>項目二</a> | <a href='#'>項目三</a> | <a href='#'>項目四</a>"
links[2]="<a href='#'>項目一</a> | <a href='#'>項目二</a> | <a href='#'>項目三</a>"
links[3]="<a href='#'>項目一</a> | <a href='#'>項目二</a> | <a href='#'>項目三</a> | <a href='#'>項目四</a> | <a href='#'>項目五</a>"
links[4]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[5]="<a href='#'>項目一</a> | <a href='#'>項目二</a> | <a href='#'>項目三</a>"
links[6]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[7]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[8]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[9]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[10]="<a href='#'>項目一</a>| <a href='#'>項目二</a>"
links[11]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
links[12]="<a href='#'>項目一</a> | <a href='#'>項目二</a>"
for (i=0;i<liArr.length;i++)
{
liArr[i].onclick=function()
{
selectThis(this,liArr,links)
}
}
}
function selectThis(indexObj,allLi,infoArr)
{
var index=0;
for (i=0;i<allLi.length;i++)
{
allLi[i].style.border="1px solid #ffffff";
allLi[i].style.backgroundColor="#86C2FF";
allLi[i].style.height="28px";
if (indexObj==allLi[i])
{
index=i;
}
}
indexObj.style.borderBottom="0px solid #666688";
indexObj.style.backgroundColor="#99cc66";
indexObj.style.height="31px";
document.getElementByIdx_x("subMenu").innerHTML=infoArr[index];
}
</script>
<body onLoad="ShowMenu()">
<div id="dNavBar" style="float:none; width:560px;"><li>首頁</li><li>娛樂快報</li><li>音樂天地</li><li>極品FLASH</li>
</div>
<div id="subMenu">站務公告</div>
</body>
</html>
B. 求幫忙調整一下javascript代碼,點擊上下箭頭切換的效果
既然用了toggle,就試一下都用toggle吧,如下:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8"/>
<title>Document</title>
<style>
body{
margin:0;
padding:0;
}
.menu{
position:fixed;
bottom:0;
left:0;
height:auto;
text-align:center;
width:100%;
cursor:pointer;
}
.title{
width:100%;
height:40px;
background:orange;
text-align:center;
}
.dropdown{
width:100%;
height:auto;
background:red;
max-height:150px;
overflow:hidden;
transition:all.5s
}
.down{
max-height:0;
}
ul{
padding:0;
margin:0;
list-style:none;
}
.triangle-top{
display:inline-block;
margin:10px;
border-top:2pxsolid;border-right:2pxsolid;
width:10px;height:10px;
transform:rotate(-45deg);
}
.triangle-bottom{
display:inline-block;
margin:10px;
border-bottom:2pxsolid;border-right:2pxsolid;
width:10px;height:10px;
transform:rotate(45deg);
}
</style>
</head>
<body>
<divclass="menu">
<divclass="dropdowndown">
<ul><li>aaa</li><li>bbb</li><li>ccc</li><ul>
</div>
<divclass="title"onclick="f()">
<spanclass="triangletriangle-top"></span>
</div>
</div>
<script>
functionf(){
document.getElementsByClassName('triangle')[0].classList.toggle('triangle-top');
document.getElementsByClassName('triangle')[0].classList.toggle('triangle-bottom');
document.getElementsByClassName('dropdown')[0].classList.toggle('down');
}
</script>
</body>
</html>
望採納,謝謝