JavaScript實(shí)現(xiàn)Tab點(diǎn)擊切換
Tab 選項(xiàng)卡切換效果在現(xiàn)如今的網(wǎng)頁中,運(yùn)用的也是比較多的,包括點(diǎn)擊切換、滑動切換、延遲切換、自動切換等多種效果,在這篇博文里,我們是通過原生 Jquery 來實(shí)現(xiàn) Tab 點(diǎn)擊切換的效果
例如:

html
<body> ? ? <div style="position: relative;margin-top: 56px;display: flex;justify-content: space-between;width: 1200px;" id="left"> ? ? ? ? <ul class="gw_b_tab"> ? ? ? ? ? ? <li class="gw_b_item gw_b_item2">111</li> ? ? ? ? ? ? <li class="gw_b_item">222</li> ? ? ? ? ? ? <li class="gw_b_item">333</li> ? ? ? ? ? ? <li class="gw_b_item">444</li> ? ? ? ? ? ? <li class="gw_b_item">555</li> ? ? ? ? ? ? <li class="gw_b_item">666</li> ? ? ? ? </ul> ? ? ? ? <div> ? ? ? ? ? ? <div class="gw_b_box" style="display: block;"> ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">111</h3> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="gw_b_box" > ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">222</h3> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="gw_b_box"> ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">333</h3> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="gw_b_box" > ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">444</h3> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="gw_b_box"> ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">555</h3> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="gw_b_box" > ? ? ? ? ? ? ? ? <h3 class="gw_box_tit">666</h3> ? ? ? ? ? ? </div> ? ? ? ? </div> </div>
css
*{
? ? ? ? ? ? padding: 0;
? ? ? ? ? ? margin: 0;
? ? ? ? }
? ? ? ? li{
? ? ? ? ? ? list-style: none; ?
? ? ? ? }
? ? ? ? .gw_b_tab{
?? ?color: #333333;
?? ?width: 240px;
?? ?height: 490px;
?? ?background: #FFFFFF;
?? ?border-radius: 8px;
?? ?overflow: hidden;
?? ?overflow-y: hidden;
}
.gw_b_item{
?? ?height: 82px;
? ? padding: 0 22px;
? ? position: relative;
? ? font-size: 16px;
? ? line-height: 80px;
?? ?text-align: center;
? ? cursor: pointer;
?? ?border-radius: 8px;
? ? font-weight: bold;
? ? white-space: nowrap;
}
.gw_b_box{
?? ?/* display: none; */
? ? width: 880px;
?? ?position: absolute;
?? ?right: 0;
?? ?top: 0;
? ? display: none;
? ? background: #FB6638;
? ? height: 490px;
? ? border-radius: 30px;
}
.gw_b_item2{
?? ?background-color: #FB6638;
?? ?color: #fff;
}
.gw_box_tit{
?? ?height: 48px;
? ? line-height: 48px;
? ? font-size: 24px;
? ? color: #ffffff;
? ? margin-bottom: 18px;
? ? text-align: center;
}js
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script>
? ? $(function () {
? ? ? ? $("#left .gw_b_item").click(function () {
? ? ? ? ? ? var index = $(this).index();
? ? ? ? ? ? $(".gw_b_box").eq(index).show();
? ? ? ? ? ? $(this).addClass('gw_b_item2')
? ? ? ? ? ? // :eq() 選擇器選取帶有指定 index 值的元素。
? ? ? ? ? ? $(".gw_b_box").eq(index).siblings().hide();
? ? ? ? ? ? $(this).siblings().removeClass('gw_b_item2')
? ? ? ? })
? ? })
</script>以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- JavaScript實(shí)現(xiàn)的簡單Tab點(diǎn)擊切換功能示例
- JavaScript 實(shí)現(xiàn) Tab 點(diǎn)擊切換實(shí)例代碼
- JS實(shí)現(xiàn)淡藍(lán)色簡潔豎向Tab點(diǎn)擊切換效果
- 簡單純js實(shí)現(xiàn)點(diǎn)擊切換TAB標(biāo)簽實(shí)例
- js實(shí)現(xiàn)點(diǎn)擊切換TAB標(biāo)簽實(shí)例
- Vue.js點(diǎn)擊切換按鈕改變內(nèi)容的實(shí)例講解
- JS實(shí)現(xiàn)的簡單標(biāo)簽點(diǎn)擊切換功能示例
- 原生JS實(shí)現(xiàn)隱藏顯示圖片 JS實(shí)現(xiàn)點(diǎn)擊切換圖片效果
- JavaScript實(shí)現(xiàn)點(diǎn)擊切換功能
- JavaScript實(shí)現(xiàn)多個重疊層點(diǎn)擊切換效果的方法
相關(guān)文章
JavaScript之map reduce_動力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要為大家詳細(xì)介紹了JavaScript之map reduce的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
javaScript實(shí)現(xiàn)滾動條事件詳解
這篇文章主要為大家詳細(xì)介紹了javaScript實(shí)現(xiàn)滾動條事件的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09
artDialog+plupload實(shí)現(xiàn)多文件上傳
這篇文章主要介紹了artDialog+plupload實(shí)現(xiàn)多文件上傳的相關(guān)資料,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07
js實(shí)現(xiàn)C#的StringBuilder效果完整實(shí)例
這篇文章主要介紹了js實(shí)現(xiàn)C#的StringBuilder效果,以完整實(shí)例形式分析總結(jié)了js實(shí)現(xiàn)C#的StringBuilder效果的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12
javascript算法學(xué)習(xí)實(shí)現(xiàn)代碼
有1到100000共10萬個數(shù)。從中隨機(jī)抽走兩個。再把原來的數(shù)字順序打亂。如何快速找到被抽走的兩個數(shù)2011-04-04
微信小程序云開發(fā)實(shí)現(xiàn)云數(shù)據(jù)庫讀寫權(quán)限
這篇文章主要為大家詳細(xì)介紹了微信小程序云開發(fā)實(shí)現(xiàn)云數(shù)據(jù)庫讀寫權(quán)限,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05
詳細(xì)總結(jié)Javascript中的焦點(diǎn)管理
相信大家都知道焦點(diǎn)作為javascript中的一個重要功能,基本上和頁面交互都離不開焦點(diǎn)。但卻少有人對焦點(diǎn)管理系統(tǒng)地做總結(jié)歸納。本文就javascript中的焦點(diǎn)管理作詳細(xì)介紹,有需要的朋友們可以參考借鑒。2016-09-09

