What is Wrong Here?


#1

This is my code, can you please tell me what is wrong here?

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.fadeOut(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-slide');
  prevDOt.addClass('active-slide');
    
});

};
$(document).ready(main);


Previous dot 2: Make sure you have defined all the variables!
#2

Hi this part

  currentDot.removeClass('active-slide');
  prevDOt.addClass('active-slide');

here

currentDot.removeClass('active-slide');

you should remove active-dot from currentDot instead of active-slide and here

  prevDOt.addClass('active-slide');

you wrote prevDOt instead of prevDot and you should also add the Class active-dot instead of active-slide


#3

Thank you very much!


#4

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