views:

37

answers:

0

I am building a website where I need to change the div class that contains image in order to manipulate the style of the next image given it is different in size and needs to be handled differently.

I have a manual slideshow system working with an array of images and an array of corresponding class names.

The problem is that the javascript changes the div class immediately before the next image is displayed and even before moving off current image and consequently the class change is applied to the current image with adverse effects before the next image appears. How do I make the class change hold out until next image is loaded?

please help if you can as I am relatively new to java and thus it is painfully difficult

sample of function below

    function nextImg() {
        if (document.images) {
            thisimg++;
            if (thisimg >= imgcnt) thisimg = 0;
            document.slideimg.src = imgs[thisimg];
            document.getElementById("wrapper").setAttribute("class", tgid[thisimg]);
        }

    }