Active Class-ERROR: Remember to fade out the current slide and remove the 'active-slide' class


#1


  1. Previous Slide 2

Remember to fade out the current slide and remove the 'active-slide' class.


var main = function() {
  $('.dropdown-toggle').click(function() {
    $('.dropdown-menu').toggle();
  });
$('.arrow-next').click(function() {
    $('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();

    if(prevSlid.lenght==0) {prevSlide=$('.slide').last();
    
    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');
    
  });
  
  
  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');
});
  
}

$(document).ready(main);


#2

@laythesmack23,
You have pasted-in
your arrow-prev =click= Eventhandler

    $('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();

    if(prevSlid.lenght==0) {prevSlide=$('.slide').last();
    
    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');
    
  });

into the middle of your
arrow-next =click= Eventhandler

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

AND
in your
if(prevSlid.lenght==0) {prevSlide=$('.slide').last();
you are using a wrong variable and then forgetting a closing-curly-bracket-}


#3

Thank you, what variable should I be using, and the curly bracket would go after the .last(); } ?


#4

@laythesmack23,
if(prevSlide.lenght==0) {prevSlide=$('.slide').last();}