码迷,mamicode.com
首页 > Web开发 > 详细

js控制多个div之间的切换

时间:2014-11-28 18:05:12      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   sp   java   on   div   cti   

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>div隐藏与显示</title>
<script type="text/javascript">
function changeBody(index){
switch(index){
case 1:{
document.getElementById(‘iDBody1‘).style.display = "";
document.getElementById(‘iDBody2‘).style.display = "none";
document.getElementById(‘iDBody3‘).style.display = "none";
break;
}
case 2:{
document.getElementById(‘iDBody1‘).style.display = "none";
document.getElementById(‘iDBody2‘).style.display = "";
document.getElementById(‘iDBody3‘).style.display = "none";
break;
}
case 3:{
document.getElementById(‘iDBody1‘).style.display = "none";
document.getElementById(‘iDBody2‘).style.display = "none";
document.getElementById(‘iDBody3‘).style.display = "";
break;
}
}
}
</script>
<a href="javascript:changeBody(1)">模块A</a>
<a href="javascript:changeBody(2)">模块B</a>
<a href="javascript:changeBody(3)">模块C</a>

<div style="display: none" id="iDBody1">模块A</div>
<div style="display: none" id="iDBody2">模块B</div>
<div style="display: none" id="iDBody3">模块C</div>
</body>
</html>

js控制多个div之间的切换

标签:style   http   io   ar   sp   java   on   div   cti   

原文地址:http://www.cnblogs.com/helinfeng/p/4128860.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!