jQuery網(wǎng)頁(yè)選項(xiàng)卡插件rTabs用法實(shí)例分析
本文實(shí)例講述了jQuery網(wǎng)頁(yè)選項(xiàng)卡插件rTabs用法。分享給大家供大家參考。具體如下:
這里介紹jQuery網(wǎng)頁(yè)選項(xiàng)卡插件rTabs用法,一共演示了4種TAB選項(xiàng)卡樣式,第一種:默認(rèn)樣式:自動(dòng)運(yùn)行、無(wú)動(dòng)畫(huà)效果、Hover事件;第二種:自動(dòng)運(yùn)行、向上滾動(dòng)、支持Hover事件的TAB選項(xiàng)卡菜單;第三種:自動(dòng)運(yùn)行、漸入淡出、支持Hover事件的選項(xiàng)卡;第四種:自動(dòng)運(yùn)行、向左滾動(dòng)、點(diǎn)擊事件的網(wǎng)頁(yè)選項(xiàng)卡,選一個(gè)你喜歡的放在你的網(wǎng)站吧。
先來(lái)看看運(yùn)行效果截圖:
在線演示地址如下:
http://demo.jb51.net/js/2015/jquery-rTabs-web-tab-cha-codes/
具體代碼如下:
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery - rTabs選項(xiàng)卡插件</title> <head> <script id="jquery_172" type="text/javascript" class="library" src="jquery-1.6.2.min.js"></script> <script type="text/javascript"> (function($){ $.fn.rTabs = function(options){ //默認(rèn)值 var defaultVal = { btnClass:'.j-tab-nav', /*按鈕的父級(jí)Class*/ conClass:'.j-tab-con', /*內(nèi)容的父級(jí)Class*/ bind:'hover', /*事件參數(shù) click,hover*/ animation:'0', /*動(dòng)畫(huà)方向 left,up,fadein,0 為無(wú)動(dòng)畫(huà)*/ speed:300, /*動(dòng)畫(huà)運(yùn)動(dòng)速度*/ delay:200, /*Tab延遲速度*/ auto:true, /*是否開(kāi)啟自動(dòng)運(yùn)行 true,false*/ autoSpeed:3000 /*自動(dòng)運(yùn)行速度*/ }; //全局變量 var obj = $.extend(defaultVal, options), evt = obj.bind, btn = $(this).find(obj.btnClass), con = $(this).find(obj.conClass), anim = obj.animation, conWidth = con.width(), conHeight = con.height(), len = con.children().length, sw = len * conWidth, sh = len * conHeight, i = 0, len,t,timer; return this.each(function(){ //判斷動(dòng)畫(huà)方向 function judgeAnim(){ var w = i * conWidth, h = i * conHeight; btn.children().removeClass('current').eq(i).addClass('current'); switch(anim){ case '0': con.children().hide().eq(i).show(); break; case 'left': con.css({position:'absolute',width:sw}).children().css({float:'left',display:'block'}).end().stop().animate({left:-w},obj.speed); break; case 'up': con.css({position:'absolute',height:sh}).children().css({display:'block'}).end().stop().animate({top:-h},obj.speed); break; case 'fadein': con.children().hide().eq(i).fadeIn(); break; } } //判斷事件類(lèi)型 if(evt == "hover"){ btn.children().hover(function(){ var j = $(this).index(); function s(){ i = j; judgeAnim(); } timer=setTimeout(s,obj.delay); }, function(){ clearTimeout(timer); }) }else{ btn.children().bind(evt,function(){ i = $(this).index(); judgeAnim(); }) } //自動(dòng)運(yùn)行 function startRun(){ t = setInterval(function(){ i++; if(i>=len){ switch(anim){ case 'left': con.stop().css({left:conWidth}); break; case 'up': con.stop().css({top:conHeight}); } i=0; } judgeAnim(); },obj.autoSpeed) } //如果自動(dòng)運(yùn)行開(kāi)啟,調(diào)用自動(dòng)運(yùn)行函數(shù) if(obj.auto){ $(this).hover(function(){ clearInterval(t); },function(){ startRun(); }) startRun(); } }) } })(jQuery); </script> <script type="text/javascript"> $(function() { $("#tab").rTabs(); $("#tab2").rTabs({ bind : 'click', animation : 'left' }); $("#tab3").rTabs({ bind : 'hover', animation : 'up' }); $("#tab4").rTabs({ bind : 'hover', animation : 'fadein' }); }) </script> <style> body{background:#fff;}h2{width: 400px;margin: 0 auto 10px auto;font-size: 18px;font-family: "微軟雅黑";color: #333;}.tab{position: relative;width: 400px;height: 230px;overflow: hidden;margin: 0 auto 20px auto;font-family: Arial;}.tab-nav{height: 30px;overflow: hidden;background: #f5f5f5;}.tab-nav a{display: block;float: left;width: 80px;height: 30px;line-height: 30px;text-align: center;text-decoration: none;color: #999;}.tab-nav a.current{background: #80b600;color: #fff;}.tab-con{position: relative;width: 400px;height: 200px;overflow: hidden;background: #80b600;}.tab-con-item{display: none;width: 400px;height: 180px;line-height: 180px;text-align: center;color: #fff;} </style> </head> <body> <h1>如果初次打開(kāi)網(wǎng)頁(yè)運(yùn)行有錯(cuò)誤看不到效果,請(qǐng)按F5或刷新網(wǎng)頁(yè)重新載入即可。</h1></br> <h2>默認(rèn)樣式:自動(dòng)運(yùn)行、無(wú)動(dòng)畫(huà)效果、Hover事件</h2> <div class="tab" id="tab"> <div class="tab-nav j-tab-nav"> <a href="javascript:void(0);" class="current">Tab1</a> <a href="javascript:void(0);">Tab2</a> <a href="javascript:void(0);">Tab3</a> <a href="javascript:void(0);">Tab4</a> <a href="javascript:void(0);">Tab5</a> </div> <div class="tab-con"> <div class="j-tab-con"> <div class="tab-con-item" style="display:block;">111111</div> <div class="tab-con-item">222222</div> <div class="tab-con-item">333333</div> <div class="tab-con-item">444444</div> <div class="tab-con-item">555555</div> </div> </div> </div> <h2>自動(dòng)運(yùn)行、向左滾動(dòng)、點(diǎn)擊事件</h2> <div class="tab" id="tab2"> <div class="tab-nav j-tab-nav"> <a href="javascript:void(0);" class="current">Tab1</a> <a href="javascript:void(0);">Tab2</a> <a href="javascript:void(0);">Tab3</a> <a href="javascript:void(0);">Tab4</a> <a href="javascript:void(0);">Tab5</a> </div> <div class="tab-con"> <div class="j-tab-con"> <div class="tab-con-item" style="display:block;">111111</div> <div class="tab-con-item">222222</div> <div class="tab-con-item">333333</div> <div class="tab-con-item">444444</div> <div class="tab-con-item">555555</div> </div> </div> </div> <h2>自動(dòng)運(yùn)行、向上滾動(dòng)、Hover事件</h2> <div class="tab" id="tab3"> <div class="tab-nav j-tab-nav"> <a href="javascript:void(0);" class="current">Tab1</a> <a href="javascript:void(0);">Tab2</a> <a href="javascript:void(0);">Tab3</a> <a href="javascript:void(0);">Tab4</a> <a href="javascript:void(0);">Tab5</a> </div> <div class="tab-con"> <div class="j-tab-con"> <div class="tab-con-item" style="display:block;">111111</div> <div class="tab-con-item">222222</div> <div class="tab-con-item">333333</div> <div class="tab-con-item">444444</div> <div class="tab-con-item">555555</div> </div> </div> </div> <h2>自動(dòng)運(yùn)行、漸入、Hover事件</h2> <div class="tab" id="tab4"> <div class="tab-nav j-tab-nav"> <a href="javascript:void(0);" class="current">Tab1</a> <a href="javascript:void(0);">Tab2</a> <a href="javascript:void(0);">Tab3</a> <a href="javascript:void(0);">Tab4</a> <a href="javascript:void(0);">Tab5</a> </div> <div class="tab-con"> <div class="j-tab-con"> <div class="tab-con-item" style="display:block;">111111</div> <div class="tab-con-item">222222</div> <div class="tab-con-item">333333</div> <div class="tab-con-item">444444</div> <div class="tab-con-item">555555</div> </div> </div> </div> </body> </html>
希望本文所述對(duì)大家的jquery程序設(shè)計(jì)有所幫助。
- jQuery實(shí)現(xiàn)的Tab滑動(dòng)選項(xiàng)卡及圖片切換(多種效果)小結(jié)
- jquery實(shí)現(xiàn)經(jīng)典的淡入淡出選項(xiàng)卡效果代碼
- jQuery實(shí)現(xiàn)仿騰訊迷你首頁(yè)選項(xiàng)卡效果代碼
- jquery實(shí)現(xiàn)超簡(jiǎn)潔的TAB選項(xiàng)卡效果代碼
- jQuery實(shí)現(xiàn)滾動(dòng)切換的tab選項(xiàng)卡效果代碼
- jquery插件tytabs.jquery.min.js實(shí)現(xiàn)漸變TAB選項(xiàng)卡效果
- jQuery實(shí)現(xiàn)tab選項(xiàng)卡效果的方法
- jQuery封裝的tab選項(xiàng)卡插件分享
- jquery實(shí)現(xiàn)標(biāo)簽支持圖文排列帶上下箭頭按鈕的選項(xiàng)卡
- jQuery簡(jiǎn)單實(shí)現(xiàn)網(wǎng)頁(yè)選項(xiàng)卡特效
- 基于jQuery實(shí)現(xiàn)的仿百度首頁(yè)滑動(dòng)選項(xiàng)卡效果代碼
相關(guān)文章
jQuery懸停文字提示框插件jquery.tooltipster.js用法示例【附demo源碼下載】
這篇文章主要介紹了jQuery懸停文字提示框插件jquery.tooltipster.js用法,涉及jQuery文字提示框插件的引入與調(diào)用實(shí)現(xiàn)技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-07-07jQuery表單元素過(guò)濾選擇器用法實(shí)例分析
這篇文章主要介紹了jQuery表單元素過(guò)濾選擇器用法,結(jié)合實(shí)例形式分析了jQuery表單元素過(guò)濾選擇器針對(duì)表單元素匹配相關(guān)操作技巧,需要的朋友可以參考下2019-02-02JQuery的read函數(shù)與js的onload不同方式實(shí)現(xiàn)
JQuery的read函數(shù)與js的onload,想必大家對(duì)這兩個(gè)方法都有所熟悉吧,接下來(lái)介紹一個(gè)實(shí)例用以上兩種方法各自實(shí)現(xiàn),感興趣的你可不要錯(cuò)過(guò)了哈,希望可以幫助到你2013-03-03jQuery實(shí)現(xiàn)類(lèi)似滑動(dòng)門(mén)切換效果的層切換
滑動(dòng)門(mén)切換效果想必大家都有見(jiàn)到過(guò)吧,在本文為大家介紹下jQuery是如何實(shí)現(xiàn)層切換的2013-09-09jQuery選擇器簡(jiǎn)明總結(jié)(含用法實(shí)例,一目了然)
jQuery 選擇器一直是 jquery 最神秘,最強(qiáng)大的一部分,當(dāng)然也是整個(gè) jquery 里面非常基礎(chǔ)的2014-04-04jQuery模板技術(shù)和數(shù)據(jù)綁定實(shí)現(xiàn)代碼
如果你用過(guò)ASP.NET的數(shù)據(jù)綁定控件,也用過(guò)ASP或者JSP里那種通過(guò)輸出HTML元素在頁(yè)面上顯示數(shù)據(jù)的方法,你就知道ASP.NET數(shù)據(jù)綁定控件有多么方便。如果能夠?qū)⑼瑯拥墓δ茉跒g覽器端用HTML和JavaScript實(shí)現(xiàn),那該是多少美妙的事情。2010-05-05