没有什么特别的东西。主要就是有了一个延迟,但效果不是特别好。。将就点了。
$.fn.gTab = function( opts ){
var options = {
'timer':0, //0.005秒
'hover':'',
'target':'',
'autoswitch':false,
'addClass':'',
'removeClass':''
};
var self = $(this);
opts = $.extend(true, {},options,opts || {});
if(!opts.target){
alert('对不起,请设置目标对象');
return ;
}
if(!opts.hover){
opts.hover = self;
}
var hoverIntervalFunc = function(index){
return setInterval(function(){
$(opts.target+':not(eq('+index+'))').hide();
$(opts.hover+':not(eq('+index+'))').removeClass(opts.addClass).addClass(opts.removeClass);
$(opts.target+':eq('+index+')').show();
$(opts.hover+':eq('+index+')').removeClass(opts.removeClass).addClass(opts.addClass);
},opts.timer);
}
$(this).hover(
function(){
var index = self.index(this);
cId = hoverIntervalFunc(index);
},
function(){
clearInterval(cId);
}
)
}
花了半小时写的。所以效果一些都没有特别的考虑。只考虑实现就完事了。。。象很多都是用的:eq和:not(:eq),事实上siblings()已经实现这个功能,但当时写的时候没翻到这个函数,就直接用:not(:eq)来解决了。

评论 (0)
暂无评论