简洁实用JavaScript Tab滑动门选项卡特效

这是一款简洁实用JavaScript tab滑动门 选项卡特效 把 onclick=”nTabs(this,0) 变成 onmouserover=”nTabs(this,0),可以做一个鼠标放上去就换内容的效果!

 

<html>
<head>
<title>简洁TAB选项卡-JS选项卡www.iiwnet.com</title>
<script type=”text/javascript”>
function nTabs(thisObj, Num) {
if (thisObj.className == “active”) return;
var tabList = document.getElementById(“myTab”).getElementsByTagName(“li”);
for (i = 0; i < tabList.length; i++) {//点击之后,其他tab变成灰色,内容隐藏,只有点击的tab和内容有属性
if (i == Num) {
thisObj.className = “active”;
document.getElementById(“myTab_Content” + i).style.display = “block”;
} else {
tabList[i].className = “normal”;
document.getElementById(“myTab_Content” + i).style.display = “none”;
}
}
}
</script>
<style type=”text/css”>
*
{
margin: 0;
padding: 0;
list-style: none;
font-size: 14px;
}
.nTab
{
width: 500px;
height: 200px;
margin: 20px auto;
border: 1px solid #dddddd;
overflow: hidden;
}
.none
{
display: none;
}
.nTab .TabTitle li
{
float: left;
cursor: pointer;
height: 35px;
line-height: 35px;
font-weight: bold;
text-align: center;
width: 124px;
}
.nTab .TabTitle li a
{
text-decoration: none;
}
.nTab .TabTitle .active
{
background: #dddddd;
color: #336699;
}
.nTab .TabTitle .normal
{
color: #F1AC1C;
}
.nTab .TabContent
{
clear: both;
overflow: hidden;
background: #fff;
padding: 5px;
display: block;
height: 100px;
}
</style>
</head>
<body>
<div class=”nTab”>
<div class=”TabTitle”>
<ul id=”myTab”>
<li class=”active” onclick=”nTabs(this,0);”>PHP学习</li>
<li class=”normal” onclick=”nTabs(this,1);”>PHP技巧</li>
<li class=”normal” onclick=”nTabs(this,2);”>CSS布局</li>
<li class=”normal” onclick=”nTabs(this,3);”>JS特效</li>
</ul>
</div>
<div class=”TabContent”>
<div id=”myTab_Content0″>
同一页面,滑动门,兼容性好 简洁TAB选项卡-JS选项卡</div>
<div id=”myTab_Content1″ class=”none”>简洁TAB选项卡-JS选项卡兼容性好</div>
<div id=”myTab_Content2″ class=”none”>简洁TAB选项卡-JS选项卡1111111</div>
<div id=”myTab_Content3″ class=”none”>简洁TAB选项卡-JS选项卡2222222</div>
</div>
</div>
</body>
</html>

发表评论

邮箱地址不会被公开。 必填项已用*标注