5. Code not Working


#1

Hey, everybody!

So, I've been working on the code for exercise 5, "Next Slide 2."

This code:

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

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

    if (nextSlide.length === 0) {
    nextSlide = $('.slide').first();
    }

    });
};

$(document).ready(main);

just doesn't want to work!

The only error I get is:
Oops, try again. When on the last slide, it looks like the next arrow isn't wrapping back to the first slide. Look back at the instructions and check the code inside the if statement.

Any help is appreciated. :slightly_smiling:


#2

Hi Anika,

These two lines need to come after your if statement :slightly_smiling:


#3

A post was split to a new topic: Exercise 5 - what's wrong with this code?