#9 Previous Slide 2


#1

indent preformatted text by 4 spaces

var main = function() {
$('.dropdown-toggle').click(function() {
$('.dropdown-menu').toggle();

});

$('.arrow-next').click(function() {
    var currentSlide = $('.active-slide');
    var nextSlide = currentSlide.next();

    var currentDot = $('.active-dot');
    var nextDot = currentDot.next();

    if (nextSlide.length == 0) {
            nextSlide = $('.slide').first();
    }; 

    if (nextDot.length == 0) {
            nextDot = $('.dot').first();
    };

    currentSlide.fadeOut(600).removeClass('active-slide');
    nextSlide.fadeIn(600).addClass('active-slide');

    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
});

$('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();

    if (prevSlide.length == 0) {
        prevslide = $('.slide').last();
    };

    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');

});

};

$(document).ready(main)

My code is above. I have been looking at it for at least an hour now and cannot figure out where I am going wrong?!? I have read all the topics that relate to this same section but still cannot see what needs changing.
The error msg reads: Oops, try again. Remember to fade in the previous slide and add the 'active-slide' class.
I have tried changing the }; after the if (prevSlide.Length ... statement to a } as this is how it appears in the hint. I still get the same error message though. :frowning: Any help would be much appreciated.


#2

Just noticed that I have a small 's' for the prevslide instead of a capital 'S'.
I have changed this and tried again but still get the same error msg.


#3

Don't know how or why but this now works. Nothing else was changed with the code. Happy days :smiley: