Issue in "Previous slide 2" lesson


#1



Hi All,

I'm stuck in lesson 9 and I can't find what I'm doing wrong. Below you can see my code, if I submit it I received an error that says "Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class."
Thanks in advance.


var main = function() {
    $('.dropdown-toggle').click(function() {
        $('.dropdown-menu').toggle();
    });
    $('.arrow-next').click(function() {
        var currentSlide = $('.active-slide');
        var nextSlide = currentSlide.next();
        
        if(nextSlide.length == 0) {
        nextSlide = $('.slide').first();
        }
        
        currentSlide.fadeOut(600).removeClass('active-slide');
        nextSlide.fadeIn(600).addClass('active-slide');
        
        var currentDot = $('.active-dot');
        var nextDot = currentDot.next();
        
        if(nextDot.length == 0) {
            nextDot = $('.dot').first();
        }
        
        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);


#2

HI the $('.arrow-prev').click(function() {..}) shoudn't be inside the $('.arrow-next').click(function() {..}) so your code should be like that

var main = function() { #open the main function

    $('.dropdown-toggle').click(function() { #open the click function '.dropdown-toggle'
       ...
    }); #close the click function '.dropdown-toggle'

    $('.arrow-next').click(function() { #open the click function '.arrow-next'
        ...
    }); #close the click function '.arrow-next'

    $('.arrow-prev').click(function() { #open the click function '.arrow-prev'
        ...
    }); #close the click function '.arrow-prev'
} #close the main function
$(document).ready(main);

#3

Thanks! I was stuck there for a week!


#4

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