JS實(shí)現(xiàn)完全語(yǔ)義化的網(wǎng)頁(yè)選項(xiàng)卡效果代碼
本文實(shí)例講述了JS實(shí)現(xiàn)完全語(yǔ)義化的網(wǎng)頁(yè)選項(xiàng)卡效果代碼。分享給大家供大家參考。具體如下:
這是一款完全語(yǔ)義化的JS網(wǎng)頁(yè)選項(xiàng)卡,包括了兩種用法,一種是點(diǎn)擊式,另一種是滑動(dòng)門式,具體用哪一種要根據(jù)你自己的需要了,滑動(dòng)門是在鼠標(biāo)經(jīng)過時(shí)觸發(fā),選項(xiàng)卡則是需要鼠標(biāo)點(diǎn)擊的。
運(yùn)行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-yyh-web-tab-cha-nav-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> <title>語(yǔ)義化的網(wǎng)頁(yè)選項(xiàng)卡</title> <style type="text/css"> *{margin:0;padding:0;font-size:13px;line-height:1.5;} body{padding:20px;} .cur{color:#f60;border-bottom:1px solid #fff;font-weight:bold;background:#fff;cursor:default;} #tab_,dl{position:relative;float:left;height:100px;width:300px;} h4,dt{float:left;height:20px;margin:0 0 0 8px;display:inline;line-height:20px;width:60px;border:1px solid #ccc;position:relative;z-index:11;text-align:center;font-weight:normal;cursor:pointer;background:#eee;} .c,dd{position:absolute;top:21px;border:1px solid #ccc;left:0;width:250px;padding:20px;overflow:hidden;display:block;} #tab_{clear:left;} h1{clear:left;padding:10px 0} #tab_1.cur{color:#f60} #tab_2.cur{color:blue} #tab_3.cur{color:green} </style> </head> <body> <h1>mouseover</h1> <dl id="tab"> <dt>美國(guó)</dt> <dd>我都不怕</dd> <dt>朝鮮</dt> <dd>誰(shuí)都怕我</dd> <dt>某國(guó)</dt> <dd>我誰(shuí)都怕</dd> </dl> <h1>click</h1> <div id="tab_"> <h4>orange</h4> <div class="c">桔紅</div> <h4>blue</h4> <div class="c">藍(lán)色</div> <h4>green</h4> <div class="c">綠色</div> </div> <script type="text/javascript"> function id(elem) {return document.getElementById(elem)} function show(elem) {elem.style.display = "";} function hide(elem) {elem.style.display = "none";} function next( elem ) { do { elem = elem.nextSibling; } while ( elem && elem.nodeType != 1 ); return elem; } function tab(a, p) { var p = (p === undefined) ? {e:"onclick",n:1} : p, node = id(a).firstChild, x = []; p.e = (p.e === undefined) ? "onclick" : p.e; p.n = (p.n === undefined) ? 1 : p.n; node=(node.nodeType !== 1)?next(node):node; for (var i = 1, node; node; i++, node = next(node)) { x[i] = node; } for (var i = 1; x[i]; i++) { if(i % 2 == 0){hide(x[i]);x[i-1].id=a+(i/2)} x[p.n*2-1].className = "cur"; show(x[p.n*2]); temp = function (i) { if (i % 2 == 1) { x[i][p.e] = function () { for (var j = 1; x[j]; j++) { if (j % 2 == 0) { hide(x[j]); x[j-1].className = "" } } show(x[i+1]); x[i].className = "cur" } } else { return null } }(i) } } tab("tab",{e:"onmouseover",n:2}); tab("tab_") </script> </body> </html>
希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。
- JS實(shí)現(xiàn)仿Windows經(jīng)典風(fēng)格的選項(xiàng)卡Tab切換代碼
- JS實(shí)現(xiàn)自動(dòng)定時(shí)切換的簡(jiǎn)潔網(wǎng)頁(yè)選項(xiàng)卡效果
- JS實(shí)現(xiàn)黑色風(fēng)格的網(wǎng)頁(yè)TAB選項(xiàng)卡效果代碼
- JS+CSS實(shí)現(xiàn)的日本門戶網(wǎng)站經(jīng)典選項(xiàng)卡導(dǎo)航效果
- JS實(shí)現(xiàn)橫向與豎向兩個(gè)選項(xiàng)卡Tab聯(lián)動(dòng)的方法
- JS基于myFocus庫(kù)實(shí)現(xiàn)各種功能的tab選項(xiàng)卡切換效果
- JS+CSS實(shí)現(xiàn)的經(jīng)典tab選項(xiàng)卡效果代碼
- JS實(shí)現(xiàn)不規(guī)則TAB選項(xiàng)卡效果代碼
- js基于面向?qū)ο髮?shí)現(xiàn)網(wǎng)頁(yè)TAB選項(xiàng)卡菜單效果代碼
- JS+CSS實(shí)現(xiàn)仿msn風(fēng)格選項(xiàng)卡效果代碼
相關(guān)文章
JS數(shù)據(jù)類型STRING使用實(shí)例解析
這篇文章主要介紹了JS數(shù)據(jù)類型STRING使用實(shí)例解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-12-12JavaScript實(shí)現(xiàn)網(wǎng)絡(luò)測(cè)速的方法詳解
在我們的日常生活中離不開網(wǎng)絡(luò),而網(wǎng)絡(luò)的快慢直接決定了用戶的產(chǎn)品使用體驗(yàn)。本文就來帶大家了解如何用JavaScript實(shí)現(xiàn)網(wǎng)絡(luò)測(cè)速,需要的可以參考一下2023-01-01實(shí)例分析JS中的相等性判斷===、 ==和Object.is()
這篇文章主要給大家介紹了關(guān)于JS中相等性判斷===、 ==和Object.is()的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用JS具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11js與jquery實(shí)時(shí)監(jiān)聽輸入框值的oninput與onpropertychange方法
這篇文章主要介紹了js與jquery實(shí)時(shí)監(jiān)聽輸入框值的oninput與onpropertychange方法,實(shí)例分析了oninput與onpropertychange實(shí)現(xiàn)下拉框里自動(dòng)匹配關(guān)鍵字實(shí)時(shí)監(jiān)聽文本框value值變化的功能,需要的朋友可以參考下2015-02-02基于JavaScript實(shí)現(xiàn)貪吃蛇游戲
這篇文章主要為大家詳細(xì)介紹了基于JavaScript實(shí)現(xiàn)貪吃蛇游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03Javascript 構(gòu)造函數(shù),公有,私有特權(quán)和靜態(tài)成員定義方法
其中公有方法聲明的部分采用的兩種方式,在實(shí)際應(yīng)用中一般采取一種方式就可以了,如果兩種方式都要采用的話,應(yīng)注意順序,防止前面寫的方法被清空或覆蓋。2009-11-11