9. Previous Slide 2


#1

I keep seeing "Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class." even after I think I got it right. Can anyone help?

This is my code:

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 nextSlide = currentSlide.prev();

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

}

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

currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');

});
}

$(document).ready(main);

Thanks for any and all help!!!


#2

Hi Tgaynor,
I've spotted a few things, please see below.

this if statement should be closed with just a bracket } to close it.

This current slide statement should be moved underneath the if nextSlide statement after the closing bracket.

then close the whole arrow-next handler.

Repeat the above steps so the arrow-prev handler is laid out in the same way as the arrow-next handler. I hope this helps.