Copy Code code as follows:
/*
The div under this will take turns to show
DNAME specifies the element to perform this action, and if no dname is specified, the default is all child elements;
TNAME specifies the activation element corresponding to the dname;
Speed display switching speed;
The effect of Effe display;
*/
(function () {
. Fn.w_picswap=function (Dname,tname,speed,effe) {
Speed=speed | | 2000;
Dname=dname | | "";
Tname=tname | | "";
Effe=effe | | 1;
Return This.each (function () {
var mytime;
var obj= (this);
var objs= (this). Find (Dname);
var objnl= (this), find (Tname), not (dname);
var len2=objnl.length;
var len=objs.length;
if (len<2) {return;}
var si=0;
var old=0;
Objs.not (': I '). CSS (' opacity ', 0);
function showimg () {
Old=si;si= (si== (len-1))? 0:si+1;
Effect (OBJS.EQ (old), Objs.eq (SI));
if (len2) {
Objnl.eq (old). Removeclass ("on");
Objnl.eq (SI). addclass ("on");
}
};
function effect (o,n) {
Switch (Effe) {
Case 1:
O.stop (). Animate ({opacity:0});
N.stop (). Animate ({opacity:1});
Break
Case 2:
var toff=o.position ();
N.stop (). CSS ("Top", Toff.top+o.outerheight ()). Animate ({top:toff.top,opacity:1},200);
O.stop (). Animate ({top:toff.top-o.outerheight (), opacity:0});
Break
}
}
Function begin () {
MyTime = SetInterval (showimg,speed);
};
Objnl.mouseover (function () {
Si=objnl.index (this);
Showimg ();
});
Slide into the Stop animation and slide out of the start animation.
Obj.hover (function () {
if (mytime) {clearinterval (mytime);}
},function () {
Begin ();
});
Begin ();
});
};
}) (JQuery);