>  기사  >  웹 프론트엔드  >  jQuery_jquery를 기반으로 한 탭 옵션 상자 효과 코드(플러그인)

jQuery_jquery를 기반으로 한 탭 옵션 상자 효과 코드(플러그인)

WBOY
WBOY원래의
2016-05-16 18:09:591065검색
复제대码 代码如下:

/**
* jQuery 플러그인
* 작성자: purecolor@foxmail.com
* 날짜: 2011-02-25
* 매개변수:
* 기본값:{
currentClass: 현재 스타일 ,
trigger: 트리거 모드,
callBack: 콜백 함수,
auto: 자동 실행 여부,
deta: 지연 시간,
index: 현재 위치
* }
* 반환: null
* 참고: 탭 옵션 상자 플러그인
*
*/
(함수($ ){
$.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),
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){
//移除自动运行
if(params.auto){
if(autoTimer)clearInterval(autoTimer);
}
move($(this).data("lvl")); /清除冒泡
if (e.stopPropagation) {
e.stopPropagation(); // Mozilla 및 Opera용
}
else if (window.event) {
window.event .cancelBubble = true; // IE
}
})
//移动播放
function move(i){
//移除上一个
items.eq(params.index).removeClass(params.currentClass);
$('.tab-content',$this).eq(params.index).hide();
//移至当前位置
items.eq(i).addClass(params.currentClass);
$('.tab-content',$this).eq(i).show();
params.index=i;
}
//自动运行
function auto(){
if(params.auto){
autoTimer=setInterval(function(){
curro=(params.index> =2)?0:(params.index 1);
이동(curro)
},params.detay);
}else{
if(autoTimer)clearInterval(autoTimer);
}
}
auto();
});
}
});
})(jQuery);

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.