Hi
I am trying to pass a a couple of arguments through a function. It is working fine when I pass the id of the slideshow div but any other argument is not recognized. I am more specifically trying to create a slideshow function for a webpage that can be used multiple times on the same page. I pass the id of the slideshow that I want to target and that part seems to work, but I also want to be able to setup individual speed (fadetime), number of images to cycle through (lastimage) and location of the images (imagePath).
In the example below the id parameter is working, but the imagePath is not. I also tried passing fadeTime and lastImage as arguments and neither of them are working as well.
var fadeTime = 200; var lastImage = 62;
var index = 1; function slideShow(id, imagePath) { //if (typeof(imagePath) === "undefined") imagePath = 'images'; $(id + ' .slideShowFront').fadeTo('medium',0); index = (index == lastImage) ? 1 : index + 1; $(".slideShowBack").attr("src", imagePath + "/" + index + ".png") setTimeout('slideShow()', fadeTime); } slideShow('#number1','images');
<div id="number1"> <img class="slideShowBack" src="images/1.png" /> <img class="slideShowFront" src="images/2.png" /> </div>