Previous slide 2 error


#1

Can anyone tell me what I'm doing wrong? Thanks so much!!!!

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

#2

Hi Caroline,

Line 5 should be moved down to just before the last line, $(document).ready(main);, because having that closing curly brace (}) right there closes main() before it should be getting closed, and results in none of the rest of the code getting run.


#3

Hiii, thank you! I've now changed this, but I still get the same error... See new code below:

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

#4

@ajaxrunner32559 Oops, I missed something else! Line 23 should have a closing parenthesis ()) after the closing curly brace (}), like this:

});

#5

Here we go! After fixing the other two things above, check line 26:

Can you spot the problem? Fixing that line will let you pass :)

Hint

You're missing the opening single quote (') right in front of .active-slide', but still inside parenthesis :)


#6

Thank you so much! Thooooough, still not working.... New code below. I appreciate your help.

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

if(prevSlide.length == 0) {
    prevSlide = $('.slide').last();

}

currentSlide.fadeOut(600).removeClass('active-slide');
prevSlide.fadeIn(600).addClass('active-slide');

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


#7

@ajaxrunner32559 You need to do everything I've suggested, including fixing line 23 :)


#8

IT WORKED!!! THANK YOU!!!!