Dot 2


#1



https://www.codecademy.com/en/courses/web-beginner-en-seyrq/0/7?content_from=make-an-interactive-website%3Ajquery-effects#


Oops, try again. When on the last slide, it looks like next arrow isn't wrapping back to the first dot. Look back at the instructions and check the code inside the if statement.


$('.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');
    });


#2

these lines of code should be after if statement

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

so your code should be like

 if (nextSlide.length == 0) {
            nextSlide = $('.slide').first();
            nextDot = $('.dot').first();
        }
currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.