I'm stuck and I need help to understand why my code isn't working


#1

hi there,
thanks for ready me and trying to help fix my problem.
I don't understand why I get the following "Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class." message when i submit my code.
Could you please help me?
here's my code :

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

$(document).ready(main);

#2

@stephanieka,
What are you doing here

 if(nextDot = $('.dot').first();

which is an invalid IF statement !!!


#3

thanks for your help!

have a nice day,
stephanie


#4

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