这个代码是不是逻辑错了?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin:0;
padding:0;
font-size:13px;
list-style:none;
}
.menu{
width:210px;
margin:50px auto;
border:1px solid #ccc;
}
.menu p{
height:25px;
line-height:25px;
font-weight:bold;
background:#eee;
border-bottom:1px solid #ccc;
cursor:pointer;
padding-left:5px;
}
.hidden{
display:none;
}
.active{
display: block;
}
.menu li{height:24px;
line-height:24px;
padding-left:5px;}
</style>
<script type="text/javascript">
window.onload=function(){
var oDiv=document.getElementById("menu");
var oPs=oDiv.getElementsByTagName("p");
var oUls=oDiv.getElementsByTagName("ul");
if(oPs.length=oUls.length){
for(var i=0;i<oPs.length;i++){
oPs[i].index=i;
oPs[i].onclick=function(){
if(oUls[this.index].className="active"){
oUls[this.index].className="hidden";
}
oUls[this.index].className="active";
}
}
}
}
</script>
</head>
<body>
<div class="menu" id="menu">
<div>
<p>Web前端</p>
<ul class="active">
<li>JavaScript</li>
<li>DIV+CSS</li>
<li>jQuery</li>
</ul>
</div>
<div>
<p>后台脚本</p>
<ul class="hidden">
<li>PHP</li>
<li>ASP.net</li>
<li>JSP</li>
</ul>
</div>
<div>
<p>前端框架</p>
<ul class="hidden">
<li>Extjs</li>
<li>Esspress</li>
<li>YUI</li>
</ul>
</div>
</div>
</body>
</html>
当我点击p的时候ul会显示但是再次点击p的时候ul就不隐藏了!是哪里出错了吗?