<html>
<head>
<title>二级菜单的制作</title>
<style type="text/css">
*{ padding:0; margin:0;}
#menu p{ width:200px; height:30px; background:black; line-height:30px; color:White;}
#menu div{ width:200px; height:100px; background:gray;}
.myshow{ display:block;}
.myhide{ display:none;}
</style>
<script type="text/javascript">
window.onload = function () {
var menup = document.getElementById("menu").getElementsByTagName("p");
var menudiv = document.getElementById("menu").getElementsByTagName("div");
var j = 0;
var ind;
for (var i = 0; i < menup.length; i++) {
menup[i].index = menudiv[i].index = i;
menup[i].onclick = function () {
ind = this.index;
menudiv[j].className = "myhide";
menudiv[ind].className = "myshow";
j = ind;
}
}
}
</script>
</head>
<body>
<div id="menu">
<p>第一章</p>
<div class="myshow">1.1</div>
<p>第二章</p>
<div class="myhide">2.1</div>
<p>第三章</p>
<div class="myhide">3.1</div>
</div>
</body>
</html>
菜单-二级菜单的制作
最新推荐文章于 2023-04-07 15:33:03 发布