My code doesn't work Next dot 1


#1



This is my code but i get the error message Remember to remove the "Active dot" from the correct dot.

 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();
            
            
        currentSlide.fadeOut(600).removeClass('active-slide');
        nextSlide.fadeIn(600).addClass('active-slide');
        
        currentDot.removeClass('active-dot');
        nextDot.addClass('active-dot');
        };
    });        
});     


$(document).ready(main);


#2

@dramos1981,
With the nextSlide.length test
your are testing if you are going past the last-Slide available
and if so
you want to set the nextSlide pointing to the first-Slide.....

You are using an IF statement structure to do this.

The build of such an IF-statement consists of

  • a_condition_ like you are using
    if (nextSlide.length == 0)
  • and an IF-code-block which is encapsulated in a pair of curly-brackets-{ }
    { nextSlide = $('.slide').first(); }

( so in short you are forgetting the closing-curly-bracket-} for your IF-code-block )

Now to the structure of your =main= function

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

================================================

++ jquery length explained AND DOM pictures of flipboard
https://www.codecademy.com/forum_questions/5615308ab62548021c0000e4


#3

ok!! it worked thanks!!


#4

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