本文实例为大家分享了js选项卡效果的具体实现代码,供大家参考,具体内容如下
效果图:
实现代码:
<style type="text/css">
body{ font-size:12px;}
.sec,.sec1{ cursor:pointer;}
.sec{ color:#FFFFFF; font-weight:bold; text-align:center; background-color:#990000;}
.sec1{ color:#990000; text-align:center; background-color:#FFFFFF;}
div{ line-height:22px;}
<script language="javascript">
function $(id){
return document.getElementById(id);
}
function xxk(num,id,ii,iii)
{
//alert(ii);
var dq;
for(var i=1;i<=num;i++)
{
if(i==id){
dq=$(ii+i).className='sec'; //当前选项
$(iii+i).style.display="block";
}
else
{
dq=$(ii+i).className='sec1';
$(iii+i).style.display="none";
}
}
}
<table width="620" border="0" cellpadding="4" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#990000">
<tr>
<td class="sec" id="t1" onmouSEOver="xxk(5,1,'t','tt')">选项卡1</td>
<td bgcolor="#FFFFFF" id="t2" class="sec1" onmouSEOver="xxk(5,2,'tt')">选项卡2</td>
<td bgcolor="#FFFFFF" id="t3" class="sec1" onmouSEOver="xxk(5,3,'tt')">选项卡3</td>
<td bgcolor="#FFFFFF" id="t4" class="sec1" onmouSEOver="xxk(5,4,'tt')">选项卡4</td>
<td bgcolor="#FFFFFF" id="t5" class="sec1" onmouSEOver="xxk(5,5,'tt')">选项卡5</td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<div id="tt1">选项卡1月在上班
<div id="tt2" style="display:none;">选项卡2月在上班