Previous slide 2 error - defining all variables


#1

Hey,

I keep getting the following error message 'Oops, try again. Make sure you have defined all the variables!'. I've pasted the code below.

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

Can anyone spot what I'm doing wrong? Thanks.


#2

in arrow-prev part your variable name is: currentSide that missing l -> currentSlide


#3

Ah! Can't believe I missed that. Thanks!


#4

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