¿Dónde falla este script para slide con jQuery?

(1/3) > >>

Linton:
Las imágenes se turnan según los intervalos estipulados... una sola vez, no sé cómo convertir la función en bucle  :-( ¿Quién me ayuda? ¡Gracias de antemano!

Código
$(document).ready(function(){
 
$("#im02,#im03,#im04,#im05").css("display","none");
 
slide();
 
function slide() {
 
$("#im01").fadeIn(2000);
$("#im01").delay(2000);
$("#im01").fadeOut(1000);
 
$("#im01").fadeOut(2000, function(){
$("#im02").fadeIn(2000);
$("#im02").delay(1000);
$("#im02").fadeOut(1000);
 
$("#im02").fadeOut(2000, function(){
$("#im03").fadeIn(2000);
$("#im03").delay(1000);
$("#im03").fadeOut(1000);
 
 
$("#im03").fadeOut(2000, function(){
$("#im04").fadeIn(2000);
$("#im04").delay(1000);
$("#im04").fadeOut(1000);
 
$("#im04").fadeOut(2000, function(){
$("#im05").fadeIn(2000);
$("#im05").delay(1000);
$("#im05").fadeOut(1000);
$.slide();
 
});
});
});
});
});
}
});

Maurice_Lupin:
Podrias utilizar setInterval.

http://stackoverflow.com/questions/10063843/jquery-create-a-loop-that-takes-one-time-interval-at-first-and-then-changes-to?answertab=votes#tab-top

Saludos.

Linton:
Gracias, voy a verlo.

Linton:
Bien, esto es el código:

Código
  // interval between items
       var itemInterval = 5500;
       var infiniteLoop;//this contains the id of the interval to be used in clearinterval by the way
       setTimeout(function(){
             // this code will run only once, one second after the page loads.
             myFunc();
             infiniteLoop = setInterval(myFunc, itemInterval);
             // commence loop that will run forever unless you use clearinterval(infiniteLoop);
       }, 1000);
       // start loop
 
       function myFunc() {
           // this code will run every time the function is called
           // initial fade out
           $('.rotating-item').eq(currentItem).fadeOut(fadeTime);
 
           // set counter
           if (currentItem == numberOfItem -1) {
               currentItem = 0;
           } else {
               currentItem++;
           }
 
           // next item fade in
           $('.rotating-item').eq(currentItem).fadeIn(fadeTime);
 
       }

...pero no veo claro el HTML, excepto que las fotos van en el div class="rotating-item". Las fotos deben llevar id según parece (//this contains the id of the interval...), ¿pero cuál? No veo luego # por ninguna parte.

Gracias, un saludo.

Maurice_Lupin:
Sólo tenias que buscar info sobre eq()
https://api.jquery.com/eq/
Código
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
 

Código
//pinta de rojo el <li> tercero
$( "li" ).eq( 2 ).css( "background-color", "red" );

En el ejemplo:

numberOfItem : total de divs con class='rotating-item'
currentItem : variable para hacer el slide

Ahora con esto quizá posteo un tuto de slide en mi blog ;D
Saludos.

Navegación

[0] Índice de Mensajes

[#] Página Siguiente