;(function($){ $.fn.lubo=function(options){ // var defaults={ // } // //通过覆盖来传参数 // var options=$.extend(defaults,options); return this.each(function(){ var _lubo=jquery('.lubo'); var _box=jquery('.lubo_box'); var _this=jquery(this); // var lubohei=_box.height(); var over='mouseover'; var out='mouseout'; var click='click'; var li="li"; var _cirbox='.cir_box'; var ciron='cir_on'; var _ciron='.cir_on'; var cirlen=_box.children(li).length; //圆点的数量 图片的数量 var lubotime=5000; //轮播时间 var switchtime=400;//图片切换时间 cir(); btn(); //根据图片的数量来生成圆点 function cir(){ _lubo.append(''); var cir_box=jquery('.cir_box'); for(var i=0; i'); } var cir_dss=cir_box.width(); cir_box.css({ left:'50%', marginleft:-cir_dss/2, bottom:'10%' }); cir_box.children(li).eq(0).addclass(ciron); } //生成左右按钮 function btn(){ _lubo.append('
'); var _btn=jquery('.lubo_btn'); _btn.append('
<
>
'); var leftbtn=jquery('.left_btn'); var rightbtn=jquery('.right_btn'); //点击左面按钮 leftbtn.bind(click,function(){ var cir_box=jquery(_cirbox); var onlen=jquery(_ciron).val(); _box.children(li).eq(onlen).stop(false,false).animate({ opacity:0 },switchtime); if(onlen==0){ onlen=cirlen; } _box.children(li).eq(onlen-1).stop(false,false).animate({ opacity:1 },switchtime); cir_box.children(li).eq(onlen-1).addclass(ciron).siblings().removeclass(ciron); }) //点击右面按钮 rightbtn.bind(click,function(){ var cir_box=jquery(_cirbox); var onlen=jquery(_ciron).val(); _box.children(li).eq(onlen).stop(false,false).animate({ opacity:0 },switchtime); if(onlen==cirlen-1){ onlen=-1; } _box.children(li).eq(onlen+1).stop(false,false).animate({ opacity:1 },switchtime); cir_box.children(li).eq(onlen+1).addclass(ciron).siblings().removeclass(ciron); }) } //定时器 int=setinterval(clock,lubotime); function clock(){ var cir_box=jquery(_cirbox); var onlen=jquery(_ciron).val(); _box.children(li).eq(onlen).stop(false,false).animate({ opacity:0 },switchtime); if(onlen==cirlen-1){ onlen=-1; } _box.children(li).eq(onlen+1).stop(false,false).animate({ opacity:1 },switchtime); cir_box.children(li).eq(onlen+1).addclass(ciron).siblings().removeclass(ciron); } // 鼠标在图片上 关闭定时器 _lubo.bind(over,function(){ cleartimeout(int); }); _lubo.bind(out,function(){ int=setinterval(clock,lubotime); }); //鼠标划过圆点 切换图片 jquery(_cirbox).children(li).bind(over,function(){ var inde = jquery(this).index(); jquery(this).addclass(ciron).siblings().removeclass(ciron); _box.children(li).stop(false,false).animate({ opacity:0 },switchtime); _box.children(li).eq(inde).stop(false,false).animate({ opacity:1 },switchtime); }); }); } })(jquery); /*调用*/ // /*css样式*/ // /*html*/ //
// //