Help with 7. Next dot 2


#1

Hello everybody! I would appreciate, if you could help me to find an error in my code. When I press Submit, i get this message: "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." Thanks!
Here is my code:

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

};

$(document).ready(main);


#2

Hi Veronika,

You need to move these two lines:

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

down to right below these two:

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

So it looks like this:

    currentSlide.fadeOut(600).removeClass('active-slide');
    nextSlide.fadeIn(600).addClass('active-slide');
        
    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
  }); // $('.arrow-next').click(function() {...
}; // var main = function() {...

Good luck with the rest of the course!


#3

Hi Zystvan! Thank you very much for your fast help! It has worked!


#4

Glad I was able to help!


#5

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