JavaScript版TAB选项卡效果实例_Javascript教程-查字典教程网
JavaScript版TAB选项卡效果实例
JavaScript版TAB选项卡效果实例
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:JavaScript版TAB选项卡functionchangeTab(id,minId,topCount){for(var...

复制代码 代码如下:

<!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=utf-8" />

<title>JavaScript版TAB选项卡</title>

<script type="text/javascript">

function changeTab(id, minId, topCount)

{

for(var i=minId; i < minId+topCount; i++)

{

if( id == i)

{

document.getElementById("li_" + i).className = "on";

document.getElementById("html_" + i).style.display = "block";

}

else

{

document.getElementById("li_" + i).className = "";

document.getElementById("html_" + i).style.display = "none";

}

}

}

</script>

<style type="text/css">

.none{display:none;}

ul,li{list-style:none; margin:0; padding:0; font-size:12px;}

.tab{margin:100px;}

.tabTitle ul{overflow:hidden; zoom:1; border-left:1px solid #D5D3D4;}

.tabTitle li{width:82px; height:30px; line-height:30px; float:left; text-align:center; background:url(/2010/07/tab1.jpg) no-repeat;}

.tabTitle li.on{background:url(/uploads/2010/07/tab2.jpg) no-repeat;}

#html_1,#html_2,#html_3,#html_4,#html_5,#html_6{border:1px solid #D5D3D4; border-top:none; width:245px; height:100px;}

</style>

</head>

<body>

<div>

<div>

<ul>

<li id="li_1" onmouseover="changeTab(1, 1, 3);">本日热门</li>

<li id="li_2" onmouseover="changeTab(2, 1, 3);">本周热门</li>

<li id="li_3" onmouseover="changeTab(3, 1, 3);">本月热门</li>

</ul>

</div>

<div id="html_1">

内容1

</div>

<div id="html_2">

内容2

</div>

<div id="html_3">

内容3

</div>

</div>

<div>

<div>

<ul>

<li id="li_4" onmouseover="changeTab(4, 4, 3);">本日推荐</li>

<li id="li_5" onmouseover="changeTab(5, 4, 3);">本周推荐</li>

<li id="li_6" onmouseover="changeTab(6, 4, 3);">本月推荐</li>

</ul>

</div>

<div id="html_4">

内容1

</div>

<div id="html_5">

内容2

</div>

<div id="html_6">

内容3

</div>

</div>

</body>

</html></td>

</tr>

</table>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类