css+javascript实现的tab切换特效代码,兼容firefox。对做模板十分有用处
代码如下:
<HR>
<script>
function hbcmsTabSwitch(o,o2,n,otag,o2tag){
var m_n = document.getElementById(o).getElementsByTagName(otag);
var c_n = document.getElementById(o2).getElementsByTagName(o2tag);
for(i=0;i<m_n.length;i++){
m_n[i].className=(i==n)?"c_tab":"h_tab";
c_n[i].className=(i==n)?"dis":"undis";
}
}
</script>
<style>
.c_tab{color:red;}.h_tab{color:gray;}
.dis{display:block;}.undis{display:none;}
</style>
<table width="290" border="0" cellpadding="0" cellspacing="0" class="newstabbg" id="nestab">
<tr id="tabnews">
<td width="71" align="center" class="s" onMouseOver="hbcmsTabSwitch('tabnews','newscot',0,'td','span')">日</td>
<td width="71" align="center" class="nos" onmouseover="hbcmsTabSwitch('tabnews','newscot',1,'td','span')">周</td>
<td width="71" align="center" class="nos" onMouseOver="hbcmsTabSwitch('tabnews','newscot',2,'td','span')">月</td>
<td width="77" height="24" align="center" class="nos" onMouseOver="hbcmsTabSwitch('tabnews','newscot',3,'td','span')">即时排行</td>
</tr>
<tr>
<td height="274" colspan="4" align="center" valign="top" class="border3" id="newscot" bgcolor="#D8EBEB">
<span class="dis">
css和javascript的
<BR>
sssss111111
</span>
<span class="undis">
s222222222
</span>
<span class="undis">
333333333333
</span>
<span class="undis">
444444444444
</span>
</td></tr></table>