miércoles, 1 de agosto de 2012

Ejemplo de uso de setInterval, if, else if, y nth-child en jQuery

he aquí el ejemplo que funciona perfect en wordpress


<script type="text/javascript">
$(document).ready(function(){


setInterval(function(){
if ( $(".noticiasSlider .post:nth-child(1)").css("display")   == "block" ){
$(".menuSlider span").css("background", "#a99e93");
$(".menuSlider span:nth-child(2)").css("background", "#227090");$(".noticiasSlider .post").fadeOut('slow');
$(".noticiasSlider .post:nth-child(2)").fadeIn('slow');
}
else if ( $(".noticiasSlider .post:nth-child(2)").css("display")   == "block" ){
$(".menuSlider span").css("background", "#a99e93");
$(".menuSlider span:nth-child(3)").css("background", "#227090");$(".noticiasSlider .post").fadeOut('slow');
$(".noticiasSlider .post:nth-child(3)").fadeIn('slow');
}
else if ( $(".noticiasSlider .post:nth-child(3)").css("display")   == "block" ){
$(".menuSlider span").css("background", "#a99e93");
$(".menuSlider span:nth-child(4)").css("background", "#227090");$(".noticiasSlider .post").fadeOut('slow');
$(".noticiasSlider .post:nth-child(4)").fadeIn('slow');
}
else if ( $(".noticiasSlider .post:nth-child(4)").css("display")   == "block" ){
$(".menuSlider span").css("background", "#a99e93");
$(".menuSlider span:nth-child(1)").css("background", "#227090");
$(".noticiasSlider .post").fadeOut('slow');
$(".noticiasSlider .post:nth-child(1)").fadeIn('slow');
}
},3000);

      });
</script>

No hay comentarios:

Publicar un comentario