Previous Slide 2: Can't figure out what's wrong with my code


#1

Just get the error:
Oops, try again. Remember to fade out the current slide and remove the ‘active-slide’ class.

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

<do not remove the three backticks above>

#2

Hi @jeremyrangel,

Look very closely at line 22 :slight_smile:


#3

Oh my…
thank you so much!


#4

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