基于JavaScript實(shí)現(xiàn)TAB標(biāo)簽效果
js實(shí)現(xiàn)tab標(biāo)簽效果,在項(xiàng)目中經(jīng)常用到,今天抽點(diǎn)時間把我寫的js實(shí)現(xiàn)tab標(biāo)簽效果源碼分享給大家,對js tab標(biāo)簽代碼需要的朋友參考下
廢話不多說了,直接給大家貼代碼了:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="JS代碼,TAB標(biāo)簽,JS廣告代碼,JS特效代碼" />
<meta name="description" content="此代碼內(nèi)容為不規(guī)則TAB選項(xiàng)卡效果,屬于站長常用代碼,更多TAB標(biāo)簽代碼請?jiān)L問腳本之家頻道。" />
<title>TAB選項(xiàng)卡效果</title>
<style type="text/css">
<!--
body,td{font-size: 12px;}
.tab{margin-top:100px}
//定義三個id
#TabTab03Con1{width:346px;height:100px;line-height:100px;border-left:#757575 1px solid;border-bottom:#757575 1px solid;border-right:#757575 1px solid;}
#TabTab03Con2{width:346px;height:100px;line-height:100px;border-left:#757575 1px solid;border-bottom:#757575 1px solid;border-right:#757575 1px solid;}
#TabTab03Con3{width:346px;height:100px;line-height:100px;border-left:#757575 1px solid;border-bottom:#757575 1px solid;border-right:#757575 1px solid;}
//定義三個標(biāo)簽類,放在標(biāo)簽頭位置,以及背景圖片的信息;
.xixi1{width:346px;height:27px;line-height:27px;background-image:url(images/01.jpg);cursor:pointer;}
.xixi2{width:346px;height:27px;line-height:27px;background-image:url(images/02.jpg);cursor:pointer;}
.xixi3{width:346px;height:27px;line-height:27px;background-image:url(images/03.jpg);cursor:pointer;}
//三個標(biāo)簽類用于初始化標(biāo)簽大小位置等信息;
.tab1{width:115px;height:27px;line-height:27px;float:left;text-align:center;cursor:pointer;}
.tab2{width:115px;height:27px;line-height:27px;float:left;text-align:center;cursor:pointer;color:#FFFFFF;}
.tab3{width:115px;height:27px;line-height:27px;float:left;text-align:center;cursor:pointer;color:#FFFFFF;}
-->
</style>
</head>
<body style="text-align:center">
<script type=text/javascript>
function setTab03Syn ( i )
{
selectTab03Syn(i);
}
//設(shè)置在不同的標(biāo)簽上點(diǎn)擊時,當(dāng)前標(biāo)簽以及其他標(biāo)簽的狀態(tài);
function selectTab03Syn ( i )
{
switch(i){
case 1:
document.getElementById("TabTab03Con1").style.display="block";
document.getElementById("TabTab03Con2").style.display="none";
document.getElementById("TabTab03Con3").style.display="none";
document.getElementById("font1").style.color="#000000";
document.getElementById("font2").style.color="#ffffff";
document.getElementById("font3").style.color="#ffffff";
break;
case 2:
document.getElementById("TabTab03Con1").style.display="none";
document.getElementById("TabTab03Con2").style.display="block";
document.getElementById("TabTab03Con3").style.display="none";
document.getElementById("font1").style.color="#ffffff";
document.getElementById("font2").style.color="#000000";
document.getElementById("font3").style.color="#ffffff";
break;
case 3:
document.getElementById("TabTab03Con1").style.display="none";
document.getElementById("TabTab03Con2").style.display="none";
document.getElementById("TabTab03Con3").style.display="block";
document.getElementById("font1").style.color="#ffffff";
document.getElementById("font2").style.color="#ffffff";
document.getElementById("font3").style.color="#000000";
break;
}
}
</script>
<div class="tab">
<div id="bg" class="xixi1">
<div id="font1" class="tab1" onMouseDown="setTab03Syn(1);document.getElementById('bg').className='xixi1'">page1</div>
<div id="font2" class="tab2" onMouseDown="setTab03Syn(2);document.getElementById('bg').className='xixi2'">page2</div>
<div id="font3" class="tab3" onMouseDown="setTab03Syn(3);document.getElementById('bg').className='xixi3'">page3</div>
</div>
<div id=TabTab03Con1> 不規(guī)則TAB選項(xiàng)卡效果1</div>
<div id=TabTab03Con2 style="display:none">不規(guī)則TAB選項(xiàng)卡效果2</div>
<div id=TabTab03Con3 style="display:none">不規(guī)則TAB選項(xiàng)卡效果3</div>
</div>
</body>
</html>
以上代碼經(jīng)小編測試過了,可以放心使用,當(dāng)然要根據(jù)個人項(xiàng)目需求,適當(dāng)?shù)脑鰟h改查,非常感謝大家對腳本之家網(wǎng)站的支持。
- js封裝tab標(biāo)簽頁實(shí)例分享
- js與jquery分別實(shí)現(xiàn)tab標(biāo)簽頁功能的方法
- 最簡單純JavaScript實(shí)現(xiàn)Tab標(biāo)簽頁切換的方式(推薦)
- 純css+js寫的一個簡單的tab標(biāo)簽頁帶樣式
- js(JavaScript)實(shí)現(xiàn)TAB標(biāo)簽切換效果的簡單實(shí)例
- js實(shí)現(xiàn)點(diǎn)擊切換TAB標(biāo)簽實(shí)例
- 簡單純js實(shí)現(xiàn)點(diǎn)擊切換TAB標(biāo)簽實(shí)例
- js實(shí)現(xiàn)的tab標(biāo)簽切換效果代碼分享
- JS實(shí)現(xiàn)常見的TAB、彈出層效果(TAB標(biāo)簽,斑馬線,遮罩層等)
- javascript實(shí)現(xiàn)不同顏色Tab標(biāo)簽切換效果
- javascript動態(tài)添加刪除tabs標(biāo)簽的方法
- JavaScript實(shí)現(xiàn)的原生態(tài)Tab標(biāo)簽頁功能【兼容IE6】
相關(guān)文章
JavaScript實(shí)現(xiàn)的貝塞爾曲線算法簡單示例
這篇文章主要介紹了JavaScript實(shí)現(xiàn)的貝塞爾曲線算法,結(jié)合簡單實(shí)例形式分析了基于javascript的貝塞爾曲線算法的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-01-01
safari,opera嵌入iframe頁面cookie讀取問題解決方法
最近做的合作網(wǎng)站嵌入到對方的iframe中去,在safari,opera和有些版本的搜狗瀏覽器(內(nèi)核版本原因)中不能讀到cookie。2010-06-06
代碼塊高亮可復(fù)制顯示js插件highlight.js+clipboard.js整合
最近有個需求是將jsp頁面上的某一段代碼塊格式化成類似CSDN的代碼塊的樣式,而且很多平臺都使用了這樣的功能,下面就為大家簡單分享一下2021-02-02
js結(jié)合正則實(shí)現(xiàn)國內(nèi)手機(jī)號段校驗(yàn)
這篇文章主要介紹了js結(jié)合正則實(shí)現(xiàn)國內(nèi)手機(jī)號段校驗(yàn)的方法以及使用js和jQuery實(shí)現(xiàn)的簡單校驗(yàn)手機(jī)號的示例,非常簡單實(shí)用,有需要的小伙伴可以參考下。2015-06-06
JS繪圖Flot如何實(shí)現(xiàn)可選顯示曲線圖功能
這篇文章主要介紹了JS繪圖Flot如何實(shí)現(xiàn)可選顯示曲線圖功能,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-10-10
在JavaScript中查找字符串中最長單詞的三種方法(推薦)
這篇文章主要介紹了在JavaScript中查找字符串中最長單詞的三種方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-01
Javascript Memoization 緩存函數(shù)使用說明
Memoization 是一種將函數(shù)返回值緩存起來的方法,學(xué)習(xí)js 面向?qū)ο蟮呐笥芽梢詤⒖枷隆?2010-05-05

