鼠标滑过选项卡切换网页内容的JS代码
2017-04-15
展开全部
<!doctype html>
<html>
<meta charset="utf-8">
<head>
<title>DIV层切换</title>
<script language="Javascript" type="text/javascript">
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";
//显示当前层
}
</script>
</head>
<body>
<a href="Javascript:;" onMouseOver="ChangeDiv('0','JKDiv_',2)">内容一</a>
<a href="Javascript:;" onMouseOver="ChangeDiv('1','JKDiv_',2)">内容二</a>
<a href="Javascript:;" onMouseOver="ChangeDiv('2','JKDiv_',2)">内容三</a>
<div id="JKDiv_0" style="font-size:14px;margin:20px;color:#FF0000;">内容部分第一区</div>
<div id="JKDiv_1" style="display:none;font-size:14px;margin:20px;color:#FF0000;">内容部分第二区</div>
<div id="JKDiv_2" style="display:none;font-size:14px;margin:20px;color:#FF0000;">内容部分第三区</div>
</body>
<html>
<meta charset="utf-8">
<head>
<title>DIV层切换</title>
<script language="Javascript" type="text/javascript">
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";
//显示当前层
}
</script>
</head>
<body>
<a href="Javascript:;" onMouseOver="ChangeDiv('0','JKDiv_',2)">内容一</a>
<a href="Javascript:;" onMouseOver="ChangeDiv('1','JKDiv_',2)">内容二</a>
<a href="Javascript:;" onMouseOver="ChangeDiv('2','JKDiv_',2)">内容三</a>
<div id="JKDiv_0" style="font-size:14px;margin:20px;color:#FF0000;">内容部分第一区</div>
<div id="JKDiv_1" style="display:none;font-size:14px;margin:20px;color:#FF0000;">内容部分第二区</div>
<div id="JKDiv_2" style="display:none;font-size:14px;margin:20px;color:#FF0000;">内容部分第三区</div>
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询