Previous dot 2 - Oops, try again. Make sure you have defined all the variables!


#1

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

Please help me with this prolem. I keep getting this error message --> Oops, try again. Make sure you have defined all the variables!
Here is my code. I appreciate your help.

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();
     }
     
 });
         
$('.arrow-prev').click(function()  { 
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();
    
    var currentDot = $('.active-dot');
    var prevDot = currentDot.prev();

       if(prevSlide.length == 0) {
        prevSlide = $('.slide').last();
        prevDot = $('.dot').last();
    }
 
    
     currentSlide.fadeOut(600).removeClass('active-slide');
     nextSlide.fadeIn(600).addClass('active-slide');
     
     
     currentDot.removeClass('active-dot');
     nextDot.addClass('active-dot');

     
 });
 
 }


$(document).ready(main);

#2

Hi in your $('.arrow-next').click(function() { .. });
Its missing this part

currentSlide.fadeOut(duration).removeClass(classNme);
nextSlide.fadeIn(duration).addClass(className);
currentDot.removeClass(className);
nextDot.addClass(className);

#4

Thanks a lot!! That solved the problem


#5

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