Previous Slide 2


#1

PLEASE HELP!-This is for a class assignment and it is due tomorrow. Any quick input would be appreciated!
Here is my code. I keep getting the message:
Oops, try again. 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() {
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();
  });

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

https://www.codecademy.com/courses/web-beginner-en-seyrq/0/9?content_from=make-an-interactive-website%3Ajquery-effects# here is the link.


#2

I went back to the lesson before, started over with that code here is the newest code.
still giving me the error message of:
Oops, try again. 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() {
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();

});

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

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

currentSlide.fadeOut(duration).removeClass('active-slide');
prevSlide.fadIn(duration).addClass('active-slide');

});
}

$(document).ready(main);


#3

Hi Amy,

Going with the code in your original post, you need to add a closing curly brace (}) to line 17. I suggest bumping the current line 17 down a line, so it looks like this:

17        }
18    });

Good luck on your assignment!


#4

I'm having the same issue. Maybe it is bug? My if statement is the same as the hint.


#5

Hey @vr_gallagher,

Please create a new forum topic with your code, the error message you're getting, and a link to the exercise you're on. I'll be happy to help you over there :)