Need help #10-previous dot 1


#1



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

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

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

$(document).ready(main);


Replace this line with your code.


#2

Hi this line..

nextSLide.fadeIn(600).addClass('active-slide');

you wrote nextSLide instead of nextSlide


#3

Thanks.
but it still does not work


#4

Hi can your post you new code?

and format your code


#5

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();
    currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');
}
currentSlide.fadeOut(600).removeClass ('active-slide'); 
nextSlide.fadeIn(600).addClass('active-slide');

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

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

if (prevSlide.length === 0) {
    prevSlide = $('.slide').last();
    prevDot = $('.dot').last();
      currentDot.removeClass('active-dot');
prevDot.addClass('active-dot');
}

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

});
};

$(document).ready(main);

this is my new one


#6

I have to aske did you pass the Lesson: Previous dot 1 ?
and on what Lesson are you now?


#7

first in $('.arrow-next').click(function() { ...}) the if statement

if (nextSlide.length === 0) {
  nextSlide = $('.slide').first();
  nextDot = $('.dot').first();
  currentDot.removeClass('active-dot');
  nextDot.addClass('active-dot');
}

these lines

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

should be ouside the if statement

then in $('.arrow-prev').click(function () { .. }) the if statement

if (prevSlide.length === 0) {
    prevSlide = $('.slide').last();
    prevDot = $('.dot').last();
    currentDot.removeClass('active-dot');
    prevDot.addClass('active-dot'); 
}

these lines ..

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

should be outside the if statement