9. Previous Slide 2


#1

Someone please help. I keep trying different Variations of this code but it doesnt work and I dont know what I am doing wrong

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 nextSlide = currentSlide.prev();

if(nextSlide.length == 0) {
        nextSlide = $('.slide').first();
}

currentSlide.fadeOut(duration).removeClass('active-slide');
nextSlide.fadeIn(duration).addClass('active-slide');
});

currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');

});
}

$(document).ready(main);


#2

Hi Tgaynor,

You've got a couple problems in your code, but they're all pretty easily fixable :)

  • You need to close the if statement on line 13 with a closing curly brace (})
  • Lines 26 and 27, you need to change duration to 600
  • Delete line 28
  • You need to create the variables currentDot and prevDot in your $('.arrow-prev').click(function(){...});
  • Line 31, nextDot needs to be prevDot

I hope this helps, please let me know if you have any questions :)