Previous Slide-Remember to fade out the current slide and remove the 'active-slide' class error

jquery

#1

Hey, I've reset the code countless times, typed it on my own, copied the hint and looked at other forum questions on the same but I just can't seem to get it right, i dont know what's wrong, please help

var main = function() {
$('.dropdown-toggle').click(function() {
    $('.dropdown-menu').toggle();
});
$('.arrow-next') .click(function() {
var currentSlide = $('.active-slide');
var nextSlide = currentSlide.next();

 $('.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'):
 });

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

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');


});
}

#2

Hi Mhernandez3,

Which exercise are you on?


#3

I am on unit 5 and I believe it is Exercise 9 on the Flipboard section


#4

The .arrow-prev function is brought before you close the .arrow next click event handler function. Each even handler should be self-contained. Whatever you want to happen when the ".arrow-next" is clicked is different from that of the even when ".arrow-prev" is clicked. This one below worked for me. You may try it:-

$('.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');
    });
    $('.arrow-next').click(function(){
        var currentSlide = ('.active-slide');
        var nextSlide = currentSlide.next();
        if(nextSlide.length == 0) {
            nextSlide = $('.slide').first();

#5

Thanks! That worked!