How to make a jQuery slider loop -


I have the following code for a slider and it works right but the slider closes after moving images from the previous image I want to make this slider loop infinitely. The code is:

  & lt; Script type = "text / javascript" & gt; $ (Function () {setInterval ("rotateImages ()", 3000);}); Function rotate images () {var oCurPhoto = $ ('# chica div.current'); Var oNxtPhoto = oCurPhoto.next (); If (oNxtPhoto.lenght == 0) onNxtPhoto = $ ('# chica div.first'); OCurPhoto.removeClass ('Current') addClass ('Previous'). Anxaxus ('on'). Animate ({opacity: 1.0}, 2000, function () {oCurPhoto.removeClass ('prevailing');}); $ ('#paintings'). Animate ({"left": "= 0"}, 1000); } & Lt; / Script & gt;  

This is HTML:

  & lt; Div class = "current" & gt; & Lt; A href = "#" & gt; & Lt; Img src = "galeria_1.jpg" alt = "Galleria de Imagens" width = "960" height = "310" square = "Galleria" /> gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; A href = "#" & gt; & Lt; Img src = "galeria_1.jpg" alt = "Galleria de Imagens" width = "960" height = "310" square = "Galleria" /> gt; & Lt; / A & gt; & Lt; / Div & gt;  

Here's the CSS:

  #chica div {position: absolute; Z-index: 0; } #chica div.previous {z-index: 1; } #chica div.current {z-index: 2; }  

If it helps here then the link to the site is ""

Why do I need to add it to the jquery code to loop it?

Stop over loop and hover? ;)

& lt; Div id = "gallery" & gt; & Lt; Div & gt; & Lt; A href = "#" & gt; & Lt; Img src = "image1.jpg" alt = "" & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; A href = "#" & gt; & Lt; Img src = "image2.jpg" alt = "" & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt;

CSS:

  # gallery IMG {status: absolute; Width: 960px; Height: 310px; }  

jq:

  var cur = 0, // Start Slide Index. We index power = 2000, // pause time (ms) fade = 500, // fade time (ms) $ ga = $ ('# gallery'), // cash gallery element $ sl = $ ('& gt; div ', $ Ga), // cache slides elements tot = $ sl.length, // We will use% tot to reset to the first slide; // mousecenter is used to empty on $ sl.hide. Eq (cur) .show (); // Hide all the slides, but one function stopFN () {explicit interval (ITV); } Function loopFn () {itv = setInterval (fadeFn, Pau); } Function fadefan () {$ sl.fadeOut (fad) .eq (++ cur% tot) .stop () FadeIn (fad); } $ Ga.hover (stopFn, loopFn); LoopFn (); // Finally, start  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -