5. Next Slide 2 - If Statement wrong?


#1

Exercise i'm stuck at:
https://www.codecademy.com/en/courses/web-beginner-en-seyrq/0/5?content_from=make-an-interactive-website%3Ajquery-effects#

Hi guys, hope one of you can help me with this problem:
You've got 4 slides on the side, when i am at the 3rd one and click on the arrow to get the last one, it first behaves right (fades in next slide), then wrong: Fades in the first slide as a second layer above the last side without me doing anything!
The expected behaviour would be me clicking on the arrow again so that the first slide of those 4 appears again.

This is the error message i get:
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.

Here's my code:

var main = function() {
    $('.dropdown-toggle').click(function(){
        $('.dropdown-menu').toggle();
    });
    
    $('.arrow-next').click(function(){
        var currentSlide = $('.active-slide');
        var nextSlide = currentSlide.next();
    
        if(nextSlide.length == 0){
            nextSlide = $('.slide').first();
        }
    
        currentSlide.fadeOut(600).removeClass('active-slide');
        nextSlide.fadeIn(600).addClass('active-Slide');
    });
}

$(document).ready(main);

#2

Hi Jonas,

Check your capitalization of active-slide on line 15 very carefully - it needs to be all lowercase :slight_smile:


#3

Aaaah!!! Thanks for help anyways - that was the mistake.


#4

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