I have the following code for the slider, and it works fine, but the slider stops after passing the images to the last. I want to make this slider loop endlessly. The code:
<script type="text/javascript">
$(function() {
setInterval("rotateImages()", 3000);
});
function rotateImages() {
var oCurPhoto = $('#chica div.current');
var oNxtPhoto = oCurPhoto.next();
if (oNxtPhoto.lenght == 0)
onNxtPhoto = $('#chica div.first');
oCurPhoto.removeClass('current').addClass('previous');
oNxtPhoto.css({opacity:0.0}).addClass('current').animate({opacity:1.0},2000,
function() {
oCurPhoto.removeClass('prevous');
});
$('#images').animate({"left": "=0"}, 1000);
}
</script>
HTML:
<div class="current">
<a href="#"><img src="galeria_1.jpg"
alt="Galeria de Imagenes" width="960" height="310" class="galeria" /></a>
</div>
<div>
<a href="#"><img src="galeria_1.jpg" alt="Galeria de Imagenes"
width="960" height="310" class="galeria" /></a>
</div>
Here is the css:
#chica div {
position: absolute;
z-index: 0;
}
#chica div.previous {
z-index: 1;
}
#chica div.current {
z-index: 2;
}
If this helps here link to the site http://negociosensanjuan.com/w/Bufetes/ "
What do I need to add to jquery code to make it a loop?
source
share