js控制多个div之间的切换
<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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。