<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding
="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function a(div) {
var divs = document.getElementsByTagName("div");//得到所有的div
for ( var i = 0; i < divs.length; i++) {
if (divs[i].id == div) {
if(divs[i + 1].style.display == "block"){
divs[i
+ 1].style.display = "none";
}
else{
divs[i
+ 1].style.display = "block";
}
}
}
}
</script>
</head>
<body>
<div id="a" onclick="a(this.id)" style="cursor: hand">首页</div>
<div id="aa" style="display: none">
<div id="a1">1</div>
<div id="a2">2</div>
<div id="a3">3</div>
<div id="a4">4</div>
</div>
<div id="b" onclick="a(this.id)" style="cursor: hand">首页</div>
<div id="bb" style="display: block">
<div id="b1">1</div>
<div id="b2">2</div>
<div id="b3">3</div>
<div id="b4">4</div>
</div>

</body>
</html>
posted on 2011-07-12 13:14  瓶叔  阅读(1255)  评论(0编辑  收藏  举报