Resetting the dot to first() doesn't work?


#1

Hi, I've now got the following code:

$('.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);
    currentSlide.removeClass('active-slide');
    nextSlide.fadeIn(600);
    nextSlide.addClass('active-slide');
});

But still the website says there's an error?


#2

Fixed it! These two lines:

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

Need to go after the if.

Tricky!