2007-06-28 17:25:06
<html>
<head>
<title>DIV层切换</title>
<script language="JavaScript" type="text/javascript">
/*********************************************
功能: 通用DIV切换函数
参数: divID --当前DIV的ID号;divName --要改变的这一组DIV的命名前缀;zDivCount --这一组DIV的个数-1
BY : JetKing 2007.06
http://www.80Boby.Com
*********************************************/
function ChangeDiv(divId,divName,zDivCount)
{
for(i=0;i<=zDivCount;i++)
{
document.getElementById(divName+i).style.display="none";
}
document.getElementById(divName+divId).style.display="block";
ChangBImg(parseInt(divId)+1);
}
function ChangBImg(zDivID)
{
var zDiv = document.getElementsByTagName('span');
for(var i=0;i<=zDiv.length;i++)
{
if(typeof(zDiv[i])=='object')
zDiv[i].className='jk_1';
}
document.getElementById('title'+zDivID).className='jk_2';
}
</script>
<style type="text/css">
<!--
body{
font-size:12px;
}
.jk_1 {
cursor:hand;
color:#3300FF;
width:180px;
height:20px;
font-weight:300;
text-align:center;
background-image: url("http://www.80boby.com/images/oproo/header_bg.gif");
}
.jk_2 {
cursor:hand;
color:#ff0000;
width:180px;
height:20px;
font-weight:800;
text-align:center;
background-color:#ccc;
}
-->
</style>
</head>
<body>
层切换示例:<br>By:JetKing(www.80Boby.Com)<br>
<span name="title" id="title1" onMouseMove="JavaScript:ChangeDiv('0','JKDiv_',2);" class="jk_1">内容一</span>
<span name="title" id="title2" onMouseMove="JavaScript:ChangeDiv('1','JKDiv_',2);" class="jk_1">内容二</span>
<span name="title" id="title3" onMouseMove="JavaScript:ChangeDiv('2','JKDiv_',2);" class="jk_1">内容三</span>
<div name="title" id="BigDIV" style="border:solid 1px #cccccc;width:460px;margin:10px;">
<div id="JKDiv_0" style="font-size:14px;margin:20px;color:#FF0000;">内容部分第一区<br> <img src="http://www.80boby.com/images/common/watermark.gif"></div>
<div id="JKDiv_1" style="display:none;font-size:14px;margin:10px;color:#FF0000;">内容部分第二区<br><img src="http://www.80boby.com/logo.gif"></div>
<div id="JKDiv_2" style="display:none;font-size:14px;margin:10px;color:#FF0000;">内容部分第三区</div>
</div>
</body>
</html>
转载于:https://www.cnblogs.com/VirtualLive/archive/2009/11/09/1598865.html