js控制点击让div滚动,显示一个,隐藏一个
以下为js代码: <script type="text/javascript"> function getDown(){ var gundong = document.getElementsByClassName("gundong"); var L = gundong.length; var show = 1; for(var i=0;i<L;i++){ if(gundong[i].style.display=='block'){ show=i; break; } } if(show+4<L){ gundong[show].style.display='none'; gundong[show+4].style.display='block'; }
}
function getUp(){ var gundong = document.getElementsByClassName("gundong"); var L = gundong.length; var show = 1; for(var i=0;i<L;i++){ if(gundong[i].style.display=='block'){ show=i; break; } } if(show-1>=0&&show+4<=L){ gundong[show-1].style.display='block'; gundong[show+3].style.display='none'; }