JS實(shí)現(xiàn)同一個(gè)網(wǎng)頁布局滑動(dòng)門和TAB選項(xiàng)卡實(shí)例
本文實(shí)例講述了JS實(shí)現(xiàn)同一個(gè)網(wǎng)頁布局滑動(dòng)門和TAB選項(xiàng)卡。分享給大家供大家參考。具體如下:
這里演示同一個(gè)網(wǎng)頁布局滑動(dòng)門和TAB選項(xiàng)卡效果,其實(shí)滑動(dòng)門和選項(xiàng)卡沒有太大的區(qū)別,無非是鼠標(biāo)動(dòng)作的不同而已,但是有時(shí)候在同一個(gè)網(wǎng)頁中布局兩個(gè)以上的選項(xiàng)卡,總?cè)菀桩a(chǎn)生混亂,導(dǎo)致JS出錯(cuò),如果你需要這樣做,那么就請(qǐng)參考本實(shí)例,幫你解決這個(gè)問題。
運(yùn)行效果截圖如下:

在線演示地址如下:
http://demo.jb51.net/js/2015/js-web-hd-tab-menu-style-codes/
具體代碼如下:
<!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>修正版的網(wǎng)頁Tab滑動(dòng)門</title>
<style>
*{margin:0;padding:0;}
body{margin:50px;font-size:12px;color:#666;}
li{list-style:none;}
.list{width:378px;height:100px;padding:10px;font-size:14px;line-height:24px;border:1px #cfedff solid;border-top:0;}
.tab{width:398px;height:34px;border:1px #cfedff solid;border-bottom:0;background:url(images/title.gif) repeat-x;}
.tab ul{margin:0;padding:0;}
.tab li{float:left;padding:0 30px;height:34px;line-height:34px;text-align:center;border-right:1px #ebf7ff solid;cursor:pointer;}
.tab li.now{color:#5299c4;background:#fff;font-weight:bold;}
.block{display:block;}
</style>
<script type="text/javascript">
function setTab(name,num,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById(name+"_"+"con"+i);
menu.className=i==num?"now":"";
con.style.display=i==num?"block":"none";
}
}
</script>
</head>
<body>
<h1>TAB切換onMouse</h1>
<div class="tab">
<ul>
<li id="one1" onmouseover="setTab('one',1,4)" class="now">儒家</li>
<li id="one2" onmouseover="setTab('one',2,4)">法家</li>
<li id="one3" onmouseover="setTab('one',3,4)">墨家</li>
<li id="one4" onmouseover="setTab('one',4,4)">道家</li>
</ul>
</div>
<div class="list">
<div id="one_con1">
<div style="background:#333;"><span>儒家,代表人物為孔丘、孟軻,代表作《春秋》、《論語》、《孟子》。 </span></div>
</div>
<div id="one_con2" style="display:none;">
<div style="background:#ff0;"><span>法家,代表人物韓非、李斯、管仲、商鞅,代表作《韓非子》、《管子》。 </span></div>
</div>
<div id="one_con3" style="display:none;">
<div style="background:#f00;"><span>墨家,代表人物墨翟,代表作《墨子》。 </span></div>
</div>
<div id="one_con4" style="display:none;">
<div style="background:#e45;"><span>道家,代表人物李耳、莊周,代表作《老子》、《莊子》。 </span></div>
</div>
</div>
<br /><br /><br />
<h1>TAB切換onClick</h1>
<div class="tab">
<ul>
<li id="two1" onclick="setTab('two',1,4)" class="now">儒家</li>
<li id="two2" onclick="setTab('two',2,4)">法家</li>
<li id="two3" onclick="setTab('two',3,4)">墨家</li>
<li id="two4" onclick="setTab('two',4,4)">道家</li>
</ul>
</div>
<div class="list">
<div id="two_con1">
<div style="background:#333;"><span>儒家,代表人物為孔丘、孟軻,代表作《春秋》、《論語》、《孟子》。 </span></div>
</div>
<div id="two_con2" style="display:none;">
<div style="background:#ff0;"><span>法家,代表人物韓非、李斯、管仲、商鞅,代表作《韓非子》、《管子》。 </span></div>
</div>
<div id="two_con3" style="display:none;">
<div style="background:#f00;"><span>墨家,代表人物墨翟,代表作《墨子》。 </span></div>
</div>
<div id="two_con4" style="display:none;">
<div style="background:#e45;"><span>道家,代表人物李耳、莊周,代表作《老子》、《莊子》。 </span></div>
</div>
</div>
</body>
</html>
希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。
- js基于面向?qū)ο髮?shí)現(xiàn)網(wǎng)頁TAB選項(xiàng)卡菜單效果代碼
- js簡單實(shí)現(xiàn)豎向tab選項(xiàng)卡的方法
- JS+CSS實(shí)現(xiàn)的經(jīng)典tab選項(xiàng)卡效果代碼
- 原生js實(shí)現(xiàn)tab選項(xiàng)卡切換
- 原生javascript實(shí)現(xiàn)Tab選項(xiàng)卡切換功能
- js實(shí)現(xiàn)類似菜單風(fēng)格的TAB選項(xiàng)卡效果代碼
- jquery插件tytabs.jquery.min.js實(shí)現(xiàn)漸變TAB選項(xiàng)卡效果
- JS實(shí)現(xiàn)不規(guī)則TAB選項(xiàng)卡效果代碼
- JS基于面向?qū)ο髮?shí)現(xiàn)的多個(gè)倒計(jì)時(shí)器功能示例
- JS基于面向?qū)ο髮?shí)現(xiàn)的選項(xiàng)卡效果示例
- 學(xué)習(xí)javascript面向?qū)ο?實(shí)例講解面向?qū)ο筮x項(xiàng)卡
- JS使用面向?qū)ο蠹夹g(shù)實(shí)現(xiàn)的tab選項(xiàng)卡效果示例
相關(guān)文章
js實(shí)現(xiàn)限定區(qū)域范圍拖拉拽效果
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)限定區(qū)域范圍拖拉拽,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11
用Javascript實(shí)現(xiàn)Windows任務(wù)管理器的代碼
在Windows系統(tǒng)上,自從98系統(tǒng)以來就提供了腳本宿主(Windows Scripting Host 簡稱WSH)的功能,WSH可以加載并運(yùn)行JS和VBS腳本,并支持調(diào)用系統(tǒng)的COM組件,在COM組件的支持下腳本可以輕松實(shí)現(xiàn)非常強(qiáng)大的功能2012-03-03
JavaScript讀取中文cookie時(shí)的亂碼問題的解決方法
讀取中文cookie時(shí)出現(xiàn)亂碼,下面是具體的解決方法,大家以后使用過程中,盡量不要用中文。2009-10-10
javascript幀動(dòng)畫(實(shí)例講解)
下面小編就為大家?guī)硪黄猨avascript幀動(dòng)畫(實(shí)例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09
javascript 根據(jù)指定字符把字符串拆分為數(shù)組
javascript 根據(jù)指定字符把字符串拆分為數(shù)組2009-05-05
uniapp的webview實(shí)現(xiàn)左滑返回上一個(gè)頁面操作方法
uniapp默認(rèn)左滑是關(guān)閉整個(gè)webview,而不是關(guān)閉當(dāng)前頁,本文給大家介紹uniapp的webview實(shí)現(xiàn)左滑返回上一個(gè)頁面操作方法,感興趣的朋友一起看看吧2023-12-12

