9. Previous Slide 2


#1

This keeps saying "Oops, try again. Remember to fade in the previous slide and add the 'active-slide' class. " I have no idea what is wrong or if it's a bug or some other third thing, but the point is I need help. Please help me.

 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 currentSlide = $('.active-slide');
         var prevSlide = currentSlide.prev();
         
         if(prevSlide.legth == 0) {
             prevSlide = $('.slide').last();
         }
         
         currentSlide.fadeOut(600).removeClass('active-slide');
         prevSlide.fadeIn(600).addClass('active-slide');
     });
 };
 
 
 $(document).ready(main);

#2

Hi this part

if(prevSlide.legth == 0)

You wrote legth instead of length


#3

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 currentSlide = $('.active-slide');
var prevSlide = currentSlide.prev();

if (prevSlide.length == 0) {
    prevSlide = $('.slide').last();
}

currentSlide.fadeOut(duration).removeClass('active-slide');
prevSlide.fadeIn(duration).addClass('active-slide');

});
};

$(document).ready(main);

Hello, I don't find I miss anything, it pops up that "make sure you have defined all the variables", I feel confused.


#4

Hi you should not post on an old post like this from 13 day ago next time you should create a new topic...

then

the error is from these lines..

currentSlide.fadeOut(duration).removeClass('active-slide');
prevSlide.fadeIn(duration).addClass('active-slide');

where you have duration you should put 600


#5

Thank you so much. I thought the concerned issue was similar, so I did not need to open a new post. I will consider the time period next time.