11. Previous Dot 2


#1

Hey guys, the error "Opps, try again. Remember to add '.active-dot' to the previous dot." keeps coming up when i try to complete the lesson, to my eyes I've to have done that. I can't work out where I've gone wrong.

I've tried refreshing my browser a couple of times to no avail.
Any help would be appreciated. Many thanks

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();
    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');

    if (nextSlide.length === 0) {
      nextSlide = $('.slide').first();
      nextDot = $('.dot').first();
    }
    currentSlide.fadeOut(600).removeClass ('active-slide'); 
    nextSlide.fadeIn(600).addClass('active-slide');
});
$('.arrow-prev').click(function () {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();
    var currentDot = $('.active-dot');
    var prevDot = currentDot.prev();

    currentDot.removeClass('active-dot');
    prevDot.addClass('active-dot');

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

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

};

$(document).ready(main);


#2

@samw92,

In your arrow-prev =click= Eventhandler
you will want to move
the code-lines

currentDot.removeClass('active-dot');
prevDot.addClass('active-dot');

to a position
AFTER your IF-statement
as you are possibly modifying the prevDot variable


#3

Thanks for the help :).


#4

Thank from me too, it worked!