Need Help Passing Function Argument Value to Another Function

What syntax do I use to pass the div_name argument value to the rotate function in the setInterval function? I can’t seem to get it to work.

function theRotator(div_name) {
    //Set the opacity of all images to 0
    $('div.'+div_name+' ul li').css({opacity: 0.0});
    //Get the first image and display it (gets set to full opacity)
    $('div.'+div_name+' ul li:first').css({opacity: 1.0});
    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds


Use an anonymous function:

setInterval(function() {
}, 6000);

The problem with what you’re doing is that you have to pass a function reference to setInterval. In what you posted, setInterval is getting the result of the rotate function (i.e. what it returns) - which could be nothing at all. It would work if you did this:

setInterval(rotate, 6000);

but since you want to pass it an argument, you need to wrap it in an anonymous function. Then setInterval will execute that function every 6s.

Raffles, That worked! Thank you so much!