js隐藏显示div

<a href="javascript:changeBody(1)">模块A</a>
<a href="javascript:changeBody(2)">模块B</a>
<a href="javascript:changeBody(3)">模块C</a>
</div>

<div style="display: none" id="iDBody1"></div>
<div style="display: none" id="iDBody2"></div>
<div style="display: none" id="iDBody3"></div>

 
function changeBody(index){

  switch(index){

    case 1:{

      document.getElementById('iDBody1').style.display = "";

      document.getElementById('iDBody2').style.display = "none";

      document.getElementById('iDBody3').style.display = "none";

    }

    case 2:{

      document.getElementById('iDBody1').style.display = "none";

      document.getElementById('iDBody2').style.display = "";

      document.getElementById('iDBody3').style.display = "none";

    }

    case 3:{

      document.getElementById('iDBody1').style.display = "none";

      document.getElementById('iDBody2').style.display = "none";

      document.getElementById('iDBody3').style.display = "";

    }

  }

}
posted @ 2014-02-27 14:40  914556495  阅读(245)  评论(0编辑  收藏  举报