Previous dot 2


#1

I'm having the same issue with this as I did with the previous slide exercise in this same segment.
this code looks right to me yet it tells me to remove the class '.active-dot' from currentDot when as far as I know i have done just that. Here is my code:

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();
    }
    if(nextDot.length == 0) {
        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');
 nextSlide.fadeIn(600).addClass('active-slide');
 
 
 currentDot.removeClass('active-dot');
 nextDot.addClass('active-dot');


 $(document).ready(main);

#2

I will find the problem for you, but can you PLEASE Read THIS Topic.. Thankyou.


#3

thank you, and yes I will read it. Sorry if I'm posting or formatting incorrectly. I'm literally 1 week into codecademy


#4

You forgot to add brackets and paranthesis to close your function. I will post stuff in the code to guilde you so please read inside carefully :smile:

 nextDot.addClass('active-dot');
   // I will comment down the Brackets you need to add...
   /* });
      )
   */
      
 $(document).ready(main);

#5

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();
        }
        if(nextDot.length == 0) {
            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');
     nextSlide.fadeIn(600).addClass('.active-slide');
     
     
     currentDot.removeClass('.active-dot');
     nextDot.addClass('.active-dot');
    });
}
 

$(document).ready(main);

its still giving me the same errors


#6

@amanuel2 please see above


#7

Ok i got it.. The problem is when you remove and add classes javascript automatically knows your working with classes so you dont need the dots behind the class name. I will show you one example error in your code and you fix all of the others like that.

Example Error:

You dont need that dot so this would be the correct format:

currentDot.removeClass('active-dot');

Hope this helped! And have a Happy Early New Year!! :fireworks: