0

I'm having trouble with a super simple slideshow I'm trying to make. I can't figure out why it won't work. The first picture shows up but it does not cycle through.

Here is the JSFiddle: http://jsfiddle.net/cydonknight/kyhxy/

and the JQuery:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

        <script type="text/javascript">
        $(document).ready(function(){
            setInterval("rotateImages()", 2000   );
        });
        function rotateImages(){
            var $onCurrent= $('#imageSlider div.current') ;


            var $onNext= $onCurrent.next().length ? $onCurrent.next();
                : $('#imageSlider div:first');

            if (!onNext.length )
                onNext=$("#imageSlider div:first");

            $onCurrent.addClass('previous');
            $onNext.css({opacity: 0.0}).addClass('current').animate({opacity:1.0}, 2000, function() {
                    $onCurrent.removeClass(' previous');
                    });


            }

    </script>

Any help would be greatly appreciated!

6
  • images are not loading in fiddle. not able to try. Commented Dec 5, 2012 at 5:40
  • change to this and try setInterval(rotateImages, 2000); Commented Dec 5, 2012 at 5:45
  • jsfiddle updated with pictures. Commented Dec 5, 2012 at 5:45
  • changes didn't make any difference Commented Dec 5, 2012 at 5:48
  • yes. i am trying. bug in this line. $onCurrent.next(); no semicolon here. Commented Dec 5, 2012 at 5:52

1 Answer 1

2

It is working now. I did lot of changes actually.

your updated fiddle

    setInterval(rotateImages, 2000);

function rotateImages()
{
var $onCurrent= $('#imageSlider div.current') ;
var $onNext= $onCurrent.next().length ? $onCurrent.next() : $('#imageSlider div:first');   

if (!$onNext.length )
    $onNext=$("#imageSlider div:first");

$("#imageSlider div").removeClass("current").css("opacity", 0);
$onNext.addClass('current').animate({opacity:1.0}, 1000);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.