I have this carousel function:
if ($.browser.msie && $.browser.version.substr(0,1)<9) {
$("ul.display li:eq(0))").show();
}
else
{
$("ul.display li:first").show();
}
$(".viewer ul li.img:first").addClass('viewerOn');
function prodCarousel(){
var aSpecimen = 0;
$('li.next a').click(function() {
$('ul.display li').hide();
$('.viewer ul li.img').siblings().removeClass('viewerOn');
aSpecimen = aSpecimen + 1;
if (aSpecimen == $('ul.display li').length + 0)
aSpecimen = 0;
if (aSpecimen == $('.viewer ul li.img').length + 0)
aSpecimen = 0;
$('ul.display li:eq(' + aSpecimen + ')').fadeIn("fast");
$('.viewer ul li.img:eq(' + aSpecimen + ')').addClass('viewerOn');
return false;
});
$('li.prev a').click(function() {
$('ul.display li').hide();
$('.viewer ul li.img').siblings().removeClass('viewerOn');
aSpecimen = aSpecimen - 1;
if (aSpecimen == -1) aSpecimen = $('ul.display li').length - 1;
$('ul.display li:eq(' + aSpecimen + ')').fadeIn("fast");
$('.viewer ul li.img:eq(' + aSpecimen + ')').addClass('viewerOn');
return false;
});
}
It works great, but since I have multiple divs on the page which use the class .dispaly, the function cycles through all of the images on the page.
What I would like is for the function to only cycle through the photos within the parent div.
I'm not sure how to do this?