基于jQuery的Tab選項(xiàng)框效果代碼(插件)
/**
* jQuery插件
* Author: purecolor@foxmail.com
* Date : 2011-02-25
* Params:
* defaults:{
currentClass:當(dāng)前樣式,
trigger:觸發(fā)方式,
callBack:回調(diào)函數(shù),
auto:是否自運(yùn)行,
detay:延遲時(shí)間,
index:當(dāng)前位置
* }
* Return: null
* Note : Tab選項(xiàng)框插件
*
*/
(function($){
$.fn.extend({
tabBuild:function(options){
return $(this).each(function(){
var defaults={
currentClass:"currentOne",
trigger:"mouseover",
callBack:null,
auto:true,
detay:3000,
index:0
}
var params=$.extend(defaults,options);
var $this=$(this);
var items=$('.tab-menu',$this),i=0;
var autoTimer,curro=0;
items.each(function(){
$(this).data('lvl',i);
if(i==params.index){
$('.tab-content',$this).eq(i).show();
$(this).addClass(params.currentClass);
}else{
$('.tab-content',$this).eq(i).hide();
}
i++;
$(this).bind(params.trigger,function(e){
//移除自動(dòng)運(yùn)行
if(params.auto){
if(autoTimer) clearInterval(autoTimer);
}
move($(this).data("lvl"));
//清除冒泡
if (e.stopPropagation) {
e.stopPropagation(); // for Mozilla and Opera
}
else if (window.event) {
window.event.cancelBubble = true; // for IE
}
});
});
//移動(dòng)播放
function move(i){
//移除上一個(gè)效果
items.eq(params.index).removeClass(params.currentClass);
$('.tab-content',$this).eq(params.index).hide();
//移至當(dāng)前位置
items.eq(i).addClass(params.currentClass);
$('.tab-content',$this).eq(i).show();
params.index=i;
}
//自動(dòng)運(yùn)行
function auto(){
if(params.auto){
autoTimer=setInterval(function(){
curro=(params.index>=2)?0:(params.index+1);
move(curro);
},params.detay);
}else{
if(autoTimer) clearInterval(autoTimer);
}
}
auto();
});
}
});
})(jQuery);
相關(guān)文章
jQuery實(shí)現(xiàn)的動(dòng)態(tài)伸縮導(dǎo)航菜單實(shí)例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的動(dòng)態(tài)伸縮導(dǎo)航菜單,實(shí)例分析了jQuery鼠標(biāo)事件及animate、hide等方法的使用技巧,需要的朋友可以參考下2015-05-05DropDownList實(shí)現(xiàn)可輸入可選擇(兩種版本可選)
本篇文章主要介紹了DropDownList實(shí)現(xiàn)可輸入可選擇的具體實(shí)現(xiàn)代碼,并附上兩種版本(js版本和jquery版本),可供大家選擇。有需要的朋友可以參考下2016-12-12jQuery插件EasyUI實(shí)現(xiàn)Layout框架頁(yè)面中彈出窗體到最頂層效果(穿越iframe)
這篇文章主要介紹了jQuery插件EasyUI實(shí)現(xiàn)Layout框架頁(yè)面中彈出窗體到最頂層效果,具有穿越iframe的功能,涉及jQuery的EasyUI插件屬性操作相關(guān)技巧,需要的朋友可以參考下2016-08-08jquery popupDialog 使用 加載jsp頁(yè)面的方法
下面小編就為大家?guī)硪黄猨query popupDialog 使用 加載jsp頁(yè)面的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-10jQuery Checkbox 全選 反選的簡(jiǎn)單實(shí)例
本文主要介紹了Checkbox的全選、反選的簡(jiǎn)單實(shí)例,需要的朋友可以參考下2016-11-11實(shí)例詳解jQuery結(jié)合GridView控件的使用方法
這篇文章主要以實(shí)例的方式詳細(xì)介紹了jQuery結(jié)合GridView控件的使用方法,感興趣的小伙伴們可以參考一下2016-01-01基于jquery實(shí)現(xiàn)的移入頁(yè)面上空文本框時(shí),讓它變?yōu)榻裹c(diǎn),移出清除焦點(diǎn)
基于jquery實(shí)現(xiàn)的移入頁(yè)面上空文本框時(shí),讓它變?yōu)榻裹c(diǎn),移出清除焦點(diǎn)的實(shí)現(xiàn)代碼。2011-07-07jQuery獲取及設(shè)置表單input各種類型值的方法小結(jié)
這篇文章主要介紹了jQuery獲取及設(shè)置表單input各種類型值的方法,總結(jié)分析了jQuery針對(duì)表單元素的各種常見操作技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2016-05-05