11. Previous dot 2 (Works properly at first...)


#1



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


I was getting a "remember to remove active-slide" error message until just now when it passed me... But my site is still buggy. My next arrow click works once properly, but then the same Anderson Cooper background keeps reappearing. My previous arrow works for three clicks, until the Anderson Cooper background keeps reappearing. I like him and all but not that much...


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

        currentSlide.fadeOut(600).removeClass('active              -slide');
        nextSlide.fadeIn(600).addClass('active-slide');
       
       currentDot.removeClass('active-dot');
       nextDot.addClass('active-dot');
    });
    
    $('.arrow-prev').click(function(){
        var currentSlide = $('.active-slide');
        var prevSlide = currentSlide.prev();
        var currentDot = $('.active-dot');
        var prevDot = currentDot.prev();
        
        if(prevSlide.length === 0) {
            prevSlide = $('.slide').last(); 
            prevDot = $('.dot').last();
        }

        currentSlide.fadeOut(600).removeClass('active              -slide');
        prevSlide.fadeIn(600).addClass('active-slide');
       
       currentDot.removeClass('active-dot');
       prevDot.addClass('active-dot');
    });
};

$(document).ready(main);


#2

@javaace59300,
Remove the extra space's

'active              -slide'

to get

'active-slide'

#3

Well that probably seems like it should have been obvious, but on my screen it wrapped so it didn't look any different than if it had been right and I didn't look that closely at my pasted code. :slight_smile: So thank you for your fresh set of eyes.


#4

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