Previous Dot 1 Error


#1



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


Error Message:
Oops, try again. It looks like previous arrow isn't moving back to the previous dot. Look back at the instructions and check the $('.arrow-prev').click() event handler


var main = function() {
    $('.dropdown-toggle').click(function(){
        $('.dropdown-menu').toggle();
    });
    $('.arrow-next').click(function() {
       var currentSlide = $('.activeSlide');
       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('.activeClass');
       nextSlide.fadeIn(600).addClass('.activeClass');
       
       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();    
       };
       
       currentSlide.fadeOut(600).removeClass('active-slide');
       prevSlide.fadeIn(600).addClass('active-slide');
    
        currentDot.removeClass('active-dot');
        prevDot.addClass('active-dot');
    
    });
};

$(document).ready(main);


I really can't find my mistake. :tired_face:


#2

your forget somethings. in part of arrow-prev > in if statement you should add a line code such as if statement in arrow-next.

this say if the slide is first by pressing arrow-prev dot and slide should go to last of that slider objects(slide and dot).


#3

But it still doesn't work...


#4

ommm now i see better your code!!!

var currentSlide = $('.activeSlide');

currentSlide.fadeOut(600).removeClass('.activeClass');
nextSlide.fadeIn(600).addClass('.activeClass');

you use somethings wrong in arrow-next
your arrow-prev code seem to fix but next arrow is wrong!
the code is for this lesson:

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');
        
        var currentDot = $('.active-dot');
        var nextDot = currentDot.next();
        if (nextDot.length === 0) {
            nextDot = $('.dot').first();
        }
        
        currentDot.removeClass('active-dot');
        nextDot.addClass('active-dot');
    });
    
    $('.arrow-prev').click(function(){
        var currentSlide = $('.active-slide');
        var prevSlide = currentSlide.prev();
        if (prevSlide.length === 0) {
            prevSlide = $('.slide').last();
        }
        
        currentSlide.fadeOut(600).removeClass('active-slide');
        prevSlide.fadeIn(600).addClass('active-slide');
        
        var currentDot = $('.active-dot');
        var prevDot = currentDot.prev();
        
        currentDot.removeClass('active-dot');
        prevDot.addClass('active-dot');
    });
};

$(document).ready(main);

#5

Thanks for the help.


#6

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