代码哪里错了导致DIV之间不能相互切换
<style type="text/css">
#tab{ width:3000px; height:400px; border:1px solid #CCC;}
#b{ width:500px; height:50px; border:1px solid #999;}
#b h3{ float:left; cursor:pointer; line-height:50px;}
#c{ width:2500px; height:259px;}
#c div{ width:300px; height:259px; float:left; background:#ccc; display:none;}
</style>
<script type="text/javascript">
var a=document.getElementById('c').getElementsByTagName('div');
var b=document.getElementsByTagName('h3')[0];
var n=0;
b.onclick=function(){
for(var i=0;i<a.length;i++){
a[i].style.display='none';
}
if(n>a.length-2){
n=0;
}
else{
++n;
}
a[n].style.display='block';
}
</script>
<body>
<div id="tab">
<div id="b"><h3>换一批</h3></div>
<div id="c">
<div style="display:block">132</div>
<div>456</div>
<div>984</div>
<div>213</div>
<div>113531</div>
</div>
</div>