当前位置: 代码迷 >> JavaScript >> js tab成效
  详细解决方案

js tab成效

热度:128   发布时间:2012-11-07 09:56:10.0
js tab效果
<head>
<title>无标题文档</title>
<style>
* {list-style-type:none; font-size:12px; text-decoration:none; margin:0; padding:0;}
.tab{  margin:20px; width:244px; height:200px; overflow:hidden; border:1px #AACCEE solid;}
.tab_b{ overflow:hidden; margin:5px; }
.menu  {overflow:hidden; }
.menu li{ display:block; float:left; display: list-item; text-align:center; width:60px; background-color:#EDF4FC;line-height:20px; border-bottom:1px #AACCEE solid;border-right:1px #AACCEE solid; }
.menu li a{ display:block;}
.menu_d{border-bottom:1px #FFFFFF solid;background-color:#FFFFFF; }
.tab ul li.aaa
{
background:#FF0000;
}
</style>
</head>
<body>
<script language="javascript">

function tabs(n)
{
var len = 4;
for (var i = 1; i <= len; i++)
{
document.getElementById('tab_a' + i).style.display = (i == n) ? 'block' : 'none';
document.getElementById('tab_' + i).className = (i == n) ? 'aaa' : 'none';
}
}
var timeout;
function delayChangeTab(m, n)
{
tabs(m );
//timeout = setTimeout('tabs(' + m + ')', n);
}
function cancelChangeTab()
{
clearTimeout(timeout);
}
    </script>
<div class="tab">
<ul class="menu" id="menutitle">
<li id="tab_1" class="aaa"><a href="javascript:void(0)" onmouseover="delayChangeTab('1',500);" onmouseout="cancelChangeTab();">新闻</a></li>
<li id="tab_2" ><a href="javascript:void(0)" onmouseover="delayChangeTab('2',500);" onmouseout="cancelChangeTab();">生活</a></li>
<li id="tab_3" ><a href="javascript:void(0)" onmouseover="delayChangeTab('3',500);" onmouseout="cancelChangeTab();">家居</a></li>
<li id="tab_4" ><a href="javascript:void(0)" onmouseover="delayChangeTab('4',500);" onmouseout="cancelChangeTab();">旅游</a></li>
</ul>
<div class="tab_b" id="tab_a1" style="display:block;"> 本地国内国际新闻<br />新浪</div>
<div class="tab_b" id="tab_a2" style="display:none;">网易  本土生活</div>
<div class="tab_b" id="tab_a3" style="display:none;">舒适居家房地产信息</div>
<div class="tab_b" id="tab_a4" style="display:none;">出行 度假</div>
</div>
</body>

?

  相关解决方案