Difficulties in 7. Next dot 2


#1



Here's the link :

https://www.codecademy.com/courses/web-beginner-en-seyrq/0/7?content_from=make-an-interactive-website%3Ajquery-effects#


Every time I click submit the error message reads:
"Oops, try again. When on the last slide, it looks like next arrow isn't wrapping back to the first dot. Look back at the instructions and check the code inside the if statement."
It seems that no matter what I do or what I change in my code it says, please see below.
I don't understand the problem.
I checked the other Topics in the Forum already and I couldn't make anything of them.
Please help. :disappointed_relieved:

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


$(document).ready(main);

Thanks for your help.


#2

The structure of the =main= function should look like

var main = function() {
     //Begin of =main= FUNCTION-BODY
        $('.dropdown-toggle').click(function(){
              $('.dropdown-menu').toggle();
        });

        $('.arrow-next').click( function() {
             //code which gets executed when =click=ed
        });
        $('.arrow-prev').click( function() {
             //code which gets executed when =click=ed
        });
     //End of =main= FUNCTION-BODY
};

And the =main= function should be executed when the document is fully loaded and READY

$(document).ready( main );

#3

Okay, thanks for telling me.


#4

My code is written exactly as shown in "Hint" Section, but I continue to get the same error message: Remove the active.dot class from current dot. Any further suggestions?


#5

@karencolbourn
Please present the full code you are using now...


#6

Please provide the full code for this. Because it doesn't work even when the code is as said in the hint.


#7

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