当前位置: 代码迷 >> HTML/CSS >> div+css js选项卡成效
  详细解决方案

div+css js选项卡成效

热度:172   发布时间:2012-10-09 10:21:45.0
div+css js选项卡效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<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;}
</style>

<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";
   }
}
}
</script>


</head>

<body>

<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,'t','tt')">选项卡2</td>
    <td bgcolor="#FFFFFF" id="t3" class="sec1" onmouseover="xxk(5,3,'t','tt')">选项卡3</td>
    <td bgcolor="#FFFFFF" id="t4" class="sec1" onmouseover="xxk(5,4,'t','tt')">选项卡4</td>
    <td bgcolor="#FFFFFF" id="t5"  class="sec1" onmouseover="xxk(5,5,'t','tt')">选项卡5</td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#FFFFFF">
<div id="tt1">选项卡1月在上班</div>
<div id="tt2" style="display:none;">选项卡2月在上班</div>
<div id="tt3" style="display:none;">选项卡3月在上班</div>
<div id="tt4" style="display:none;">选项卡4月在上班</div>
<div id="tt5" style="display:none;">选项卡5月在上班</div>
</td>
  </tr>
</table>
<br />
<table width="620" border="0" cellpadding="4" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#990000">
  <tr>
    <td class="sec" id="ts1" onclick="xxk(4,1,'ts','tts')">选项卡1</td>
    <td bgcolor="#FFFFFF" id="ts2" class="sec1" onclick="xxk(4,2,'ts','tts')">选项卡2</td>
    <td bgcolor="#FFFFFF" id="ts3" class="sec1" onclick="xxk(4,3,'ts','tts')">选项卡3</td>
    <td bgcolor="#FFFFFF" id="ts4" class="sec1" onclick="xxk(4,4,'ts','tts')">选项卡4</td>
  </tr>
  <tr>
    <td colspan="4" bgcolor="#FFFFFF">
<div id="tts1">选项卡1月在上班</div>
<div id="tts2" style="display:none;">选项卡2月在上班</div>
<div id="tts3" style="display:none;">选项卡3月在上班</div>
<div id="tts4" style="display:none;">选项卡4月在上班</div>
</td>
  </tr>
</table>


</body>
</html>
  相关解决方案