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操作動(dòng)畫(huà)完整實(shí)例分析
這篇文章主要介紹了jQuery操作動(dòng)畫(huà),結(jié)合完整實(shí)例形式分析了jquery針對(duì)頁(yè)面元素動(dòng)畫(huà)效果相關(guān)實(shí)現(xiàn)技巧,涉及jquery slideUp與slideDown方法的使用,需要的朋友可以參考下2020-01-01
jQuery EasyUI API 中文幫助文檔和擴(kuò)展實(shí)例
這篇文章主要介紹了jQuery EasyUI API 中文幫助文檔和擴(kuò)展實(shí)例 的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08
jQuery實(shí)現(xiàn)滑動(dòng)星星評(píng)分效果(每日分享)
jQuery星星評(píng)分制作5顆星星鼠標(biāo)滑過(guò)評(píng)分打分效果,可取消評(píng)分結(jié)果,重新打分。下面通過(guò)代碼給大家講解的非常詳細(xì),需要的的朋友參考下2019-11-11
jQuery:delegate中select()不起作用的解決方法(實(shí)例講解)
本篇文章只要是對(duì)jQuery:delegate中select()不起作用的解決方法進(jìn)行了詳細(xì)的介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01
jQuery實(shí)現(xiàn)為table表格動(dòng)態(tài)添加或刪除tr功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)為table表格動(dòng)態(tài)添加或刪除tr功能,結(jié)合實(shí)例形式分析了jQuery針對(duì)table表格行動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-02-02
實(shí)例解析jQuery插件EasyUI最常用的表單驗(yàn)證規(guī)則
這篇文章主要以實(shí)例解析了jQuery插件EasyUI最常用的驗(yàn)證規(guī)則,對(duì)EasyUI校驗(yàn)感興趣的小伙伴們可以參考一下2015-11-11

